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. Therefore, I installed Apache and then PHP on my local PC and expected to be able to test the PHP script locally, but it does not return the expected information. Below 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>
Below is the code for 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 this works when used on the Internet, but why it doesn't work locally. I checked that apache and php are installed correctly. What could be the problem? The current result is a table with the $ key and the $ value in places where the correct values should be, in other words, in the table cells. Thank you for your help.
UPDATE: now works, although WAMPSERVER- thanks to everyone who helped!
Andrew