AnthonyWC
AnthonyWC

Reputation: 1960

PHP in html not parsing

I have a html file and I want to run PHP code to call out an array value within HTML form box but the interpreter doesn't recognize

<input value="<?php echo $_SESSION['user']; ?>"/>

p.s. Not sure if it makes any difference but I am running this on cloud9 with apache (httpd).

Upvotes: 2

Views: 1529

Answers (3)

AnthonyWC
AnthonyWC

Reputation: 1960

Ok I figured out that it was actually working all along =/ (i was only looking at the local IDE display within cloud9 but the code was working all along since it actually required back-end processing and the local IDE won't display that).

Upvotes: 0

user2684521
user2684521

Reputation: 380

Save your HTML file as a PHP file since HTML files cannot execute php code. For example if your file is named index.html you want to re-save it as index.php once you do that your php code should run.

Upvotes: 5

Ashish Choudhary
Ashish Choudhary

Reputation: 2034

HTML files does not parse PHP. You need to have a file with .php as extension to run PHP.

PS: Its possible to make HTML file run PHP as well but that requires some extra settings in apache config which is never enabled by default. Reason being a security threat. But If you have a dedicated server which allows playing with apache config then you can achieve this.. have a look at this LINK

Upvotes: 1

Related Questions