Showing posts with label button. Show all posts
Showing posts with label button. Show all posts

Friday, May 13, 2016

How To Add Radio Button Value In Database In PHP

Today I will share a working script example which will help you to insert radio button value in database using PHP.

<?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>
?>

This simple script will enable you to add radio button values in database easily.Hope you found this post useful.

Enjoy!