Tenho esse Form html:
<form id="addRunner" name="addRunner" action="service.php" method="POST">
First Name: <input type="text" name="txtFirstName" id="txtFirstName" value="" placeholder="Firt Name"><br>
Last Name: <input type="text" name="txtLastName" id="txtLastName" value="" placeholder="Last Name"><br>
Gender: <select name="ddlGender" id="ddlGender">
<option value="">--Please Select--</option>
<option value="">Female</option>
<option value="">Male</option>
</select><br>
Finish Time: <input type="text" name="txtMinutes" id="txtMinutes" value="" placeholder="(minutes)" maxlength="2">
<input type="text" name="txtSeconds" id="txtSeconds" size="10" maxlength="2" value="txtSeconds" placeholder="(seconds)">
<br><br>
<button type="submit" name="btnSave" id="btnSave">Add Runner</button>
<input type="hidden" name="action[]" id="action[]" value="addRunner">
</form>
Esse código PHP deveria fazer a validação e gravação na base da informações enviadas pelo Form, porém nada é gravado na Base. Alguém pode me ajudar?
$a_html = filter_input(INPUT_POST, 'action', FILTER_SANITIZE_SPECIAL_CHARS);
if ($a_html === 'addRunner') {
$fname = htmlspecialchars(isset($_POST['txtFirstName']) ? $_POST['txtFirstName'] : 'txtFirstName');
$lname = htmlspecialchars(isset($_POST['txtLastName']) ? $_POST['txtLastName'] : 'txtLastName');
$gender = htmlspecialchars(isset($_POST['ddlGender']) ? $_POST['ddlGender'] : 'Valor Padrão');
$minutes = htmlspecialchars(isset($_POST['txtMinutes']) ? $_POST['txtMinutes'] : 'ddlGender');
$seconds = htmlspecialchars(isset($_POST['txtSeconds']) ? $_POST['txtSeconds'] : 'txtSeconds');
$time = $minutes . ':' . $seconds;
if (preg_match('/[^\w\s]/i', $fname) || preg_match('/[^\w\s]/i', $lname)) {
echo 'Invalid name provided';
}
if (empty($gender)) {
echo 'Gender select a please';
}
$string_sql = "INSERT INTO testemunho (first_name, last_name, gender, finish_time) VALUES (null,'{$fname}','{$lname}','{$gender}','{$time}')";
$result = mysqli_query($conect, $string_sql);
if ($result) {
echo 'Runners: ', "$fname","$lname" . "Added Sucess";
} else {
echo 'Erro ao gravar dados';
}
}