2

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).

AnthonyC
  • 1,880
  • 2
  • 20
  • 27

3 Answers3

5

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.

user2684521
  • 380
  • 4
  • 20
1

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

Community
  • 1
  • 1
Ashish Choudhary
  • 2,004
  • 1
  • 18
  • 26
  • That link seems very useful; unfortunately I seem to lack permission to modify httpd.conf and .htaccess seems disabled. I did email their support to see if they have a workaround. Also php5 module is enabled; I can actually run other php code fine but it just doesn't recognize . I was thinking maybe there was a need to escape that since it is not interpreting – AnthonyC Oct 13 '15 at 22:19
0

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).

AnthonyC
  • 1,880
  • 2
  • 20
  • 27