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 <chrisstinem...@gmail.com>
To: rquadl...@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



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to