Re: Re: radio form submission
| From: | Chris Stinemetz | Date: | Fri, 24 Jun 2011 18:44:05 +0000 |
| Subject: | Re: Re: radio form submission | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-313708@lists.php.net to get a copy of this message | ||
#### radio select validation ####
What I am doing wrong?
I want to make sure a radio button is selected, but my current code
allows insertion even when radio button isn't selected.
My code is:
//Generating radio buttons for store type with array
echo 'Store type:<br /><br />';
$choices = array('corporate' => 'Cricket owned | ',
'premier' => 'Premier dealer');
foreach ($choices as $key => $choice) {
echo "<input type='radio' name='store_type'
value='$key'/>
$choice \n";
}
//Validate the radio button submission
if (!array_key_exists($_POST['store_type'], $choices)) {
echo "You must select a valid choice.";
}
Thanks