New to PHP and web development in general. I am trying to get information from an HTML form to appear in a table on another web page after clicking submit. So I installed Apache and then PHP on my local PC and expected to be able to test a PHP script locally however it does not return the information I was expecting. The following is the code for the form:
<form method="post" action="showform.php">
Please fill out the following form if you would like to be contacted: <br/>
Name:<input type="text" name="name" /> <br/><br/>
Company: <input type="text" name="company"/> <br/><br/>
Phone: <input type="text" name="phone" /> <br/><br/>
Email: <input type="text" name="email" /> <br/><br/>
<input type="submit" name="Submit" value="Submit" />
</form>
The following is the code for the php script:
<table>
<tr><th>Field Name</th><th>Value(s)</th></tr>
<?php
if (empty($_POST)) {
print "<p>No data was submitted.</p>";
} else {
foreach ($_POST as $key => $value) {
if (get_magic_quotes_gpc()) $value=stripslashes($value);
if ($key=='extras') {
if (is_array($_POST['extras']) ){
print "<tr><td><code>$key</code></td><td>";
foreach ($_POST['extras'] as $value) {
print "<i>$value</i><br />";
}
print "</td></tr>";
} else {
print "<tr><td><code>$key</code></td><td><i>$value</i></td></tr>\n";
}
} else {
print "<tr><td><code>$key</code></td><td><i>$value</i></td></tr>\n";
}
}
}
?>
</table>
</body>
</html>
I know it works when used on the internet but how come it doesn't work locally. I have checked that apache and php are installed correctly. What could be the issue? The current result is a table with $key and $value in the places where the correct values should be, in other words in the table cells. Thanks for your help.
UPDATE: Now working though WAMPSERVER- thanks to all who helped!