xkyogre Posted July 10, 2007 Share Posted July 10, 2007 I have a form that needs to be checked. It contains 4 radio boxes a submit button and 4 different hidden fields. How do I get my php script to check if a radio box has been selected and tell the user to check a radio box if he hasn't? The script I am currently using doesn't work; if the user chacks some thing then it proceeds as usual, but if it is left blank then the program freezes up and nothing is displayed apart from the stuff outside the <?php?> tags. Link to comment https://forums.phpfreaks.com/topic/59316-processing-radio-boxes-and-hidden-form-fields-at-the-same-time/ Share on other sites More sharing options...
GingerRobot Posted July 10, 2007 Share Posted July 10, 2007 Do you think we could see your code that you have? Dont forget to enclose it in tags(without the spaces) However, to answer what i think is your question, say you had the following radio button: [code] <input type='radio' name='yourfield' value='option1' /> Then to check if this option had been selected, you would use: <?php if($_POST['yourfield'] = 'option1'){ //option1 selected } ?> Of course, if your form method was get, use the $_GET array. Link to comment https://forums.phpfreaks.com/topic/59316-processing-radio-boxes-and-hidden-form-fields-at-the-same-time/#findComment-294724 Share on other sites More sharing options...
xkyogre Posted July 11, 2007 Author Share Posted July 11, 2007 <?php foreach($_POST as $field => $value){ if($field == 'crime'){ if($value == " ") { $blob = 1; } } } if($blob == 1) { #redisplay form } else{ #show results } Link to comment https://forums.phpfreaks.com/topic/59316-processing-radio-boxes-and-hidden-form-fields-at-the-same-time/#findComment-295490 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.