Today I will share a working script example which will help you to insert radio button value in database using PHP.
Enjoy!
This simple script will enable you to add radio button values in database easily.Hope you found this post useful.<?php
if(isset($_POST[submit]))
{
$number=$_POST[number];
if($number!="")
{
$query=mysql_query("UPDATE users SET number = $number WHERE name = ".$user->name.";");
if($query)
{
header(Location: /me);
}
else
{
$error_message = <font color="red"><strong>Please choose a number.</strong></font><br /><br />;
}
}
}
?>
<form method="post" action="">
<input type="radio" name="number" value="1" />1
<input type="radio" name="number" value="2" />2
<input type="radio" name="number" value="3" />3
<input type="submit" name="submit" />
</form>
?>
Enjoy!