Page 1 of 1

How to check which radio button is selected?

Posted: Mon May 17, 2004 10:52 am
by mjseaden
Dear All,

I have radio buttons on a form. When I press submit, how do I determine on the receiving code which radio button has been selected, since they both have the same name? (Some PHP would be great to demonstrate!)

Many thanks

Mark

Posted: Mon May 17, 2004 10:55 am
by lostboy
If they have the same name, then you check the values

Code: Select all

$radio = $_POST['RadioButtonName'];

if ( $radio == "x" ){ 
  //do something
}else[if ($radio=="y"]){
  //do something else
}