Check if a radio button has been checked - php Form

Author Topic: Check if a radio button has been checked  (Read 2869 times)

Offline admin

  • Administrator
  • *****
  • Posts: 67
  • Karma: +10/-0
  • Gender: Male
    • View Profile
Check if a radio button has been checked
« on: January 26, 2010, 01:04:47 AM »


Code: [Select]
<?php
if(isset($_POST['submit']))
{
$fradio $_POST['fradio'];
if (
strlen($fradio) == 0) {
echo 
"<center>FALSE:<a href=\"javascript:history.go(-1)\">Go Back</a></center>";  
 Die();
}else{
echo 
"<center>TRUE:<a href=\"javascript:history.go(-1)\">Go Back</a></center>";
}  
}else{
?>

<form method="post" action="check.php">
<input type="radio" name="fradio" value="1">1
<input type="radio" name="fradio" value="2">2
<input type="submit" name="submit" value="submit">
</form>
<?php
}
?>