I need help. I've built a form which sends all fields to a MySQL database via php. The problem is this: Certain fields are being written to the database while others are not.
I tested inserting values into my database through PHPMyAdmin on my server and it worked. All fields I entered were stored. So there's a problem, I assume, with the PHP code. And seeing as I'm very new to PHP I won't be surprised if this is the case.
Below is the code for contact.html and submitform.php.
**The values from fields "FirstName", "LastName" & "Accommodation" always work but "Guest", "Response", "Email" &"Phone" never do.
//contact.html
<form action=submitform.php method=POST>
<table border="0">
<tr>
<td width="120">First Name:</td>
<td width="304"><input type="text" name="FirstName" size="15" />
Last Name: <input type="text" name="LastName" size="15" /></td>
</tr>
<tr>
<td>Guest (leave blank if none):</td>
<td><input type="text" name="Guest" size="30" /></td>
</tr>
<tr>
<td>Phone Number:</td>
<td><input type="text" name="Phone" /></td>
</tr>
<tr>
<td>E-mail:</td>
<td><input type="text" name="Email" size="30" /></td>
</tr>
</table>
<p>I will be:<br />
<input type="radio" name="Response" value="Attending">attending<br />
<input type="radio" name="Response" value="Not Attending">not attending<br />
<input type="radio" name="Response" value="Sending Money Joke">not attending but sending lots of money!</p>
<p>I will be staying at:
<select name="Accommodation">
<option value="HCC">HCC</option>
<option value="West Coast">West Coast Inn</option>
<option value="Bayfield Inn">Bayfield Inn</option>
<option value="Clair on Square">Clair on the Square</option>
<option value="Other">Other</option>
</select></p>
<p>Comments?<br />
<textarea name="Comments" cols="40" rows="6"></textarea></p>
<br />
<br />
<input type="submit" value="Send Me" />
</form>
//SUBMITFORM.PHP
<html>
<body>
<?php
mysql_connect (localhost, username, password);
mysql_select_db (davea_guest);
mysql_query ("INSERT INTO guest (LastName, FirstName, Guest, Accommodation, Email, Phone, Response)
VALUES ('$LastName', '$FirstName', '$Guest', '$Accommodation', '$Email', '$Phone', '$Response'
)
");
print ("Thanks for submitting your name.");
?>
</body>
</html>