I’ve taken the following code and placed them in their respective files. I’ve opened up register.html in Firefox and after entering the required details to the form it loads welcome.php albeit with out the entered information. The loaded page simply reads: “Welcome! You are years old!”
Both files are stored in the same folder.
Any suggestions on what I’m doing wrong?
register.html
<html>
<body>
<form action="welcome.php" method="post">
Name: <input type="text" name="fname" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>
</body>
</html>
welcome.php
Welcome <?php echo $_POST["fname"]; ?>!<br />
You are <?php echo $_POST["age"]; ?> years old.
</body>
</html>
For Apache:
1) Ensure the
mimemodule is on.2) Try making an
.htaccessfile in the same directory, with the following contents:This will only work if the
rewritemodule is on.3) Otherwise, if you have access to the
httpd.conffile, try adding that line somewhere in it, without the.htaccessfile.Make sure to restart the server any time you make changes to
httpd.conf.Edit:
I should have also mentioned to view source of the page, to see if the PHP code is in it. which would make these steps necessary.
Another troubleshooting technique is to add
<?php error_reporting(E_ALL); ?>at the top of the page, in case PHP actually is running and since there are no errors. If it is disabled, it will enable reporting anUndefined indexnotice. It seems highly unlikely that it would be the case, but it also seems like a useful step that could help us understand exactly what’s going on. Then again, I’m pretty sure PHP just isn’t executing.