I've currently got a prepared statement that puts the data from an HTML form through a Prepared Statement (PHP) into a SQL database.
The problem here; one field remains empty after putting it into the DB. The 'gender' field, which is an ENUM(M,F,O). The rest gets filled up with the right data.
Is there any way for me to get the gender into the table along with the other data?
The relevant HTML:
<input type="radio" id="man" name="gender" value="man">
<label for="man">Man</label>
<input type="radio" id="woman" name="gender" value="woman">
<label for="woman">Woman</label>
<input type="radio" id="other" name="gender" value="other">
<label for="other">Other</label>
The PHP:
$firstname= htmlentities($_POST['firstname'], ENT_QUOTES);
$lastname= htmlentities($_POST['lastname'], ENT_QUOTES);
$gender= htmlentities($_POST['gender'], ENT_QUOTES);
$birthdate= preg_replace("([^0-9-])", "", $_POST['birthday'], ENT_QUOTES);
$email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
$portfolio = filter_var($_POST['portfolio'], FILTER_SANITIZE_URL);
$query = "INSERT INTO `table` (`firstname`, `lastname`, `gender`, `birthdate`, `email`, `portfolio`)
VALUES (?, ?, ?, ?, ?, ?)";
mysqli_stmt_bind_param($stmt, "ssssss", $firstname, $lastname, $gender, $birthdate, $email, $portfolio);
mysqli_stmt_execute($stmt);
$prepstmt = mysqli_stmt_get_result($stmt);
htmlentities()when saving into the DB. That should only be used when displaying text on a web page.