Re: Re: radio form submission
| From: | Andre Polykanine | Date: | Fri, 24 Jun 2011 22:24:10 +0000 |
| Subject: | Re: Re: radio form submission | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-313714@lists.php.net to get a copy of this message | ||
Hello Chris,
Maybe I'm off topic, but wouldn't you consider JavaScript form
validation? That will make your task easier and the user will see
his/her error much earlier, before he/she submits the form.
--
With best regards from Ukraine,
Andre
Skype: Francophile
My blog: http://oire.org/menelion (mostly in Russian)
Twitter: http://twitter.com/m_elensule
Facebook: http://facebook.com/menelion
------------ Original message ------------
From: Chris Stinemetz <chrisstinemetz@gmail.com>
To: RQuadling@gmail.com
Date created: , 9:44:05 PM
Subject: [PHP] Re: [PHP-DB] Re: radio form submission
#### 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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php