Av@Tech
Learner
How to store radio button value in database on button click
How to store radio button value in database on button click
Share
<!doctype html>
<html>
<head>
</head>
<body>
<h3>Store Radio Button value to MySQL database</h3>
<form method=”post” action=””>
<input type=”radio” name=”gender” value=”Male”><label>Male</label><br/>
<input type=”radio” name=”gender” value=”Female”><label>Female</label><br/>
<input type=”submit” name=”submit” Value=”submit”>
</form>
<?php include ‘dbconfig.php’;
if (isset($_POST[‘submit’]))
{
$gen = $_POST[“gender”];
$query = “INSERT INTO studentinfo (gender) VALUES (‘”.$gen.”‘)”;
mysql_query($query) or die(mysql_error());
echo “Data saved”;
}
?>
</body>
</html>