How to insert form data into MySQL database table
- by Richard
So I have this registration script:
The HTML:
<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
$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, thanks.