So I have this registration script:
The HTML:
HTML Code:
<form action="register.php" method="POST">
<label>Username:</label> <input type="text" name="username" /><br />
<label>Password:</label> <input type="text" name="password" /><br />
<label>Gender:</label>
<select name="gender">
<optgroup label="genderset">
<option value="Male">Male</option>
<option value="Female">Female</option>
<option value="Hermaphrodite">Hermaphrodite</option>
<option value="Not Sure!!!">Not Sure!!!</option>
</optgroup>
</select><br />
<input type="submit" value="Register" />
</form>
The PHP/SQL:
PHP Code:
<?php
$username = $_POST['username']; $password = $_POST['password']; $gender = $_POST['gender'];
mysql_query("INSERT INTO registration_info (username, password, gender) VALUES ('$username', '$password', '$gender') ")
?>
The problem is, the username and password gets inserted into the
"registration_info" table just fine. But the Gender input from the
select drop down menu doesn't. Can some one tell me how to fix this,
P.S. I know this is an unsafe script as I am inserting form data directly into the database without validating it in any way first. That's because I am just learning PHP/SQL and want to get the basics down first. This script will never actually go online.
thanks.
|