siddscool19 Posted September 21, 2008 Share Posted September 21, 2008 <html> <body> <form method=get> <input type=radio name=gender id=male >Male</br> <input type=radio name=gender id=female >Female</br> <input type=submit value=Submit> </form> </body> </html> <?php $gender=$_GET["gender"]; echo $gender ?> Now i want the value of only <input type=radio name=gender id=male > .. What coding is to be used? Link to comment https://forums.phpfreaks.com/topic/125154-how-to-get-value-from-radio-button-in-php-using-id/ Share on other sites More sharing options...
ratcateme Posted September 21, 2008 Share Posted September 21, 2008 add a value field to your buttons so one is value=male... Scott. Link to comment https://forums.phpfreaks.com/topic/125154-how-to-get-value-from-radio-button-in-php-using-id/#findComment-646886 Share on other sites More sharing options...
siddscool19 Posted September 21, 2008 Author Share Posted September 21, 2008 That i don't want to do......... I just want that if field come from male then it accepts otherwise it doesn't accepts how to do that? Link to comment https://forums.phpfreaks.com/topic/125154-how-to-get-value-from-radio-button-in-php-using-id/#findComment-646889 Share on other sites More sharing options...
chronister Posted September 21, 2008 Share Posted September 21, 2008 You HAVE to add a value= to your radios otherwise they have no value <input type=radio name=gender value="male" id=male >Male</br> <input type=radio name=gender value='female" id=female >Female</br> Then do this.... <?php $gender = $_GET['gender']; if($gender == 'male') { echo 'Its a boy!!'; } else { echo 'Throw her back'; } ?> Basic HTML structure and php comparison operators. Nate Link to comment https://forums.phpfreaks.com/topic/125154-how-to-get-value-from-radio-button-in-php-using-id/#findComment-646892 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.