What do I do differently?
Code: Select all
<!-- Gender Form --!>
<select name="gender">
<option value="na" selected>Gender</option>
<option value="m">Male</option>
<option value="f">Female</option>
</select><br /><br />Moderator: General Moderators
Code: Select all
<!-- Gender Form --!>
<select name="gender">
<option value="na" selected>Gender</option>
<option value="m">Male</option>
<option value="f">Female</option>
</select><br /><br />Code: Select all
<html>
<body>
<?php
$con = mysql_connect("localhost","root","root");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("Database1", $con);
$sql="INSERT INTO Accounts (FirstName, LastName, Email, Username, Password, Gender, DOBMonth, DOBDay, DOBYear, Country, State)
VALUES
('$_POST[firstname]','$_POST[lastname]','$_POST[email]','$_POST[username]','$_POST[password]','$_POST[gender]','$_POST[month]','$_POST[day]','$_POST[year]','$_POST[country]','$_POST[state]')";
if (mysql_query($sql,$con))
{
echo("Congratulations. You've successfully added a user into the database.");
}
else
{
die('Error: ' . mysql_error());
}
echo "Record added";
mysql_close($con)
?>
</body>
</html>
Look at your HTML and just think for a second.CKEANEDesign wrote:When I use the POST method to insert it into MySQL Database, it comes up as the value name for the form object, (the radio is gender between male and female). So it will come out m or f instead of the written option name like "Male" or "Female."
What do I do differently?
Code: Select all
<select name="gender">
<option value="na">Gender</option>
<option value="male">Male</option>
<option value="female">Female</option>
</select>Code: Select all
<label><input type="radio" name="gender" value="m" /> Male</label>
<label><input type="radio" name="gender" value="f" /> Female</label>
<label><input type="radio" name="gender" value="na" /> No Comment</label>