PDA

View Full Version : _POST radio buttons in a form


chriskq
11-26-2007, 03:28 AM
Hey all, coming back into php, had a few months off and im already feeling abit rusty.

basically little unsure on how to submit a radio button answer.

lets say in a form you have to select male or female radio button.
how do we parse this as a true value.

$male= $_POST['male'];
$female= $_POST['female']

$body = ...
Male: $male\n
Female: $female\n

how do i set the value to true for whichever radio button is selected.

davidj
11-26-2007, 06:45 AM
radio buttons are named the same in the same group but the values are different. When catching radio values just employ one $_POST

example ...

$radio = $_POST['radio'];

then you just have to perform logic on the value


switch ($radio){

case 'male': /* do stuff here */; break;
case 'female': /* do stuff here */; break;

}

chriskq
11-27-2007, 03:54 AM
ah Dj im a idiot, i was forgetting about the value tags.

working now :)