I am trying to work on a contact form with PHP, HTML and MYSQL. Everything works except for the radiobuttons. When i select the button 'male' it doesnt show that in the database. I tried to specify the radiobuttons with an ID, unfortunately that did not worked out for me. Could you guys help me with this? Thanks!
HTML
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Contact formulier</title>
</head>
<body>
<fieldset>
<legend>Contact Form</legend>
<form name="frmContact" method="post" action="contact.php">
<p>
<label for="Name">Name </label>
<input type="text" name="txtName" id="txtName">
</p>
<p>
<input type="radio" name="gender" value="Male">Male</br>
<input type="radio" name="gender" value="Female">Female
</p>
<p>
<label for="phone">Phone</label>
<input type="text" name="txtPhone" id="txtPhone">
</p>
<p>
<label for="message">Message</label>
<textarea name="txtMessage" id="txtMessage"></textarea>
</p>
<p> </p>
<p>
<input type="submit" name="Submit" id="Submit" value="Submit">
</p>
</form>
</fieldset>
</body>
</html> ```
PHP
// database connection code
// $con = mysqli_connect('localhost', 'database_user', 'database_password','database');
$con = mysqli_connect('localhost', 'root', '','db_connect');
// get the post records
$txtName = $_POST['txtName'];
$gender = $_POST['gender'];
$txtPhone = $_POST['txtPhone'];
$txtMessage = $_POST['txtMessage'];
// database insert SQL code
$sql = "INSERT INTO `tbl_contact` (`Id`, `fldName`, 'gender', `fldPhone`, `fldMessage`) VALUES ('0', '$txtName', '$gender', '$txtPhone', '$txtMessage')";
// insert in database
$rs = mysqli_query($con, $sql);
if($rs)
{
echo "Contact Records Inserted";
}else{
echo "Contact records failed";
}
?> ```