My PHP script not running

(http://markjeffery.42web.io/login.html)

I have a very simple php script:

<!DOCTYPE html>
<html>
<body>
<?php
print "<h1>Mc Donalds</h1>";
print "Burger!<br>";
print "I'm Loving It!<br>";
?>
</body>
</html>

The output looks like this:

Mc Donalds"; print "Burger!
"; print "I’m Loving It!
"; ?>

So it appears that php is not running / configured
It is a new account and I wonder if I have failed to some essential bit of configuration?

Sorry - I included the page source code in my message and it has tried to run it. trying again with it commented out!

//<!DOCTYPE html>
//<html>
//<body>
//<?php
//print "<h1>Mc Donalds</h1>";
//print "Burger!<br>";
//print "I'm Loving It!<br>";
//?>
//</body>
//</html>

Epic fail on me trying to include code in my question!!
basically a very simple php page that i stole from w3schools at

You can put code in your messages, but be sure to also format it as code. You can use HTML to format your posts (along with BBCode and Markdown), so if you just dump HTML in the message box, the forum will try to parse it for formatting.


As for your question itself:

Please note that on our hosting (and most PHP installations) only files with the .php extension are executed as PHP code. If you put PHP code in a file with the .html extension, the code won’t be executed and is just sent to the browser. If you rename the file to login.php, the PHP code will be executed.

If you want the URL to have the .html extension because you think it’s prettier, you can use .htaccess rules to direct a request to file.html to the script file.php.

5 Likes

Thank you very much.
Now I feel very stupid!!! years since I wrote and php and completely forgot the basics.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.