I need some help with radio button data and how to code it in PHP to insert the data into MySQL.
Here is my Form Code:
<form method="post" action="update.php">
First Name: <br />
<input type="text" name="fname" size="35" /><br />
Last Name: <br />
<input type="text" name="lname" size="35" /><br />
Phone Number: <br />
<input type="text" name="phone" size="12" /><br />
Company:<br />
<input type="text" name="Company" size="30" /><br />
Email:<br />
<input type="text" name="Email" size="30" /> <br />
<input type="radio" name="field" value="SPM" />Sr. Project Manager<br />
<input type="radio" name="field" value="PM" />Project Manager<br />
<input type="radio" name="field" value="CEST" />Chief Estimator<br />
<input type="radio" name="field" value="EST" />Estimator<br />
<input type="radio" name="field" value="PE" />Project Engineer<br />
<input type="radio" name="field" value="SI" />Superintendent<br />
<input type="radio" name="field" value="OTH" />Other<br />
<input type="submit" value="Submit!" />
</form>
And here is my PHP:
<?php
$con = mysql_connect("server.mysql.com","user","********");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("database", $con);
$sql="INSERT INTO ContactList (ID, fname, lname, phone, Company, Email) VALUES ('NULL', '$_POST[fname]','$_POST[lname]','$_POST[phone]', '$_POST[Company]', '$_POST[Email]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($con)
?>
I tried a few times already but I have not been successful in using correct code to make the radio buttons work. The table is already built for the data, I just need help with inserting.
This code works--I need to know what to add for the radio buttons.
Thank you in advance.