I am trying to make a contact form to give input on another browser window. I am only getting the php code. I am trying to figure out why it won't post. Her is my html and php files:
<!DOCTYPE html>
<html>
<head>
<title>Contact</title>
<link rel="stylesheet" href="main.css">
</head>
<body>
<h1>Contact Form</h1>
<nav>
<ul>
<li><a
href="index.html">Home</a></li>
<li><a href="page2.html">My
PodCast</a></li>
<li><a href="page3.html">Contact
Me</a></li>
<li><a
href="page4.html">Resources</a></li>
<li><a href="addressbook.html">Address
Book</a></li>
<li>Contact Form</li>
</ul>
</nav>
<center><h2>Please fill out form</h2>
<div id='container'>
<div id='header'></div>
<center><h3>Contact</h3>
<form name="contact" method="post" action="contact.php">
<table width="450px">
<tr>
<td valign="top">
<label for="first_name">First Name *</label>
</td>
<td valign="top">
<input type="text" name="first_name" maxlength="50"
size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="last_name">Last Name *</label>
</td>
<td valign="top">
<input type="text" name="last_name" maxlength="50"
size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="email">Email Address *</label>
</td>
<td valign="top">
<input type="text" name="email" maxlength="80"
size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="telephone">Telephone Number</label>
</td>
<td valign="top">
<input type="text" name="telephone" maxlength="30"
size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="comments">Comments *</label>
</td>
<td valign="top">
<textarea name="comments" maxlength="1000" cols="25"
rows="6"></textarea>
</td>
</tr>
<tr>
<td colspan="2" style="text-align:center">
<input type="submit">
</td>
</tr>
</table>
</form>
</center> <div id='footer'></div>
</div>
</body>
</html>
PHP File:
<!DOCTYPE html>
<html>
<body>
<?php
echo "<h2>Your information:</h2>";
echo $_POST["first_name"];
echo "<br>";
echo $_POST["last_name"];
echo "<br>";
echo $_POST["email"];
echo "<br>";
echo $_POST["telephone"];
echo "<br>";
echo $_POST["comments"];
?>
</body>
</html>
THe form is not getting posted because of the small mistake in the opening of form tag. The HTTP parameters are all case sensitive and will not work with proper case. In the given code the form opened as <form name="contact" method="post" action="contact.php"> and "post" is coded in small case. As per the rule, get and post should be in upper case for working. Therefore the opening tag should include "POST" (post in uppercase).
<form name="contact" method="POST" action="contact.php">
Get Answers For Free
Most questions answered within 1 hours.