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

2
  • 2
    Sounds like PHP is not enabled at the apache module leve. Commented Oct 13, 2015 at 18:03
  • 1
    You need to have php 5 installed for this to run. Commented Oct 13, 2015 at 18:04

3 Answers 3

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.

Sign up to request clarification or add additional context in comments.

Comments

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

1 Comment

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 <?php while inside a http <value>. I was thinking maybe there was a need to escape that since it is not interpreting <?php as a code tag.
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).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.