I want to use radio buttons in my application.When i click Male , i want it to input male into the database, when i click Female, it sends female into the database.
Code looks like this
<html>
<head></head>
<title>Radio Test</title>
<body>
<h1>Radio Test</h1>
<form name="testform" id="testform" method="post" action="test.php" />
Name : <input type="text" name="fullname" id="fullname" /></br>
Male <input type="radio" name="male" id="male" value="Male" />
Female <input type="radio" name="female" id="female" value="FeMale" /></br></p>
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>
For the HTML Area, Now i want to make it output values, but it doesnt respond. My PHP looks like this but instead of sending one value, it sends both
<?php
$host = "127.0.0.1"
$user = "root"
$pass = ""
$db = "people_info"
$con = mysqli_connect($host, $user, $pass, $db) or die('Cannot Connect :'.mysqli_error());
$fullname = mysqli_real_escape_string($con, $_POST['fullname']);
$male = mysqli_real_escape_string($con, $_POST['male']);
$female = mysqli_real_escape_string($con, $_POST['female']);
$sql = "insert into data (fullname,male,female) values ('".$fullname."', '".$male."', '".$female."')";
mysqli_query($con,$sql) or die ('Failed Query :'.mysqli_error($con));
mysqli_close($con);
?>
I was thinking of using switch case, but that made it even worse. It didnt send any values as well..