我正在注册表格,我在其中有些字段可以正常工作,但是当我添加性别部分时,我的PHP无法识别$ _POST变量中的性别。 以下是我的HTML:
<div class="form-group label-floating is-select">
<label class="control-label">Your Gender</label>
<select class="selectpicker name="gender" form-control" size="auto">
<option value="MA">Male</option>
<option value="FE">Female</option>
</select>
</div>
以下是我的php:
if (isset($_POST['regButton'])) {
$i = 0;
$username = strtolower($_POST['fname'] . $_POST['lname'] . $i++ );
$password = $_POST['password'];
$FirstName = $_POST['fname'];
$LastName = $_POST['lname'];
$usermail = $_POST['email'];
$dob = $_POST['datetimepicker'];
$gender = $_POST['gender'];
$query = "INSERT INTO users(username, password, FirstName, LastName, Email, dob, gender) ";
$query .= "VALUES ('$username', '$password', '$FirstName', '$LastName', '$usermail', '$dob', '$gender')";
$result = mysqli_query($con, $query);
if(!$result){
echo "<div class='alert alert-danger'>Query Failed.</div>";
}else {
echo "<div class='alert alert-danger'>Registraation Successful.</div>";
}
}
我该怎么办?请帮帮我。