RE: [PHP] form validataion?

From: Date: Wed, 08 Aug 2001 20:00:02 +0000
Subject: RE: [PHP] form validataion?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-61898@lists.php.net to get a copy of this message
Usually if-statements and regex's are used to validate data... If you just want to make sure the form is filled out completely, you could do this: (which is how I do it) if(empty($name) || empty($address) || empty($phone)) { // Form is not complete echo 'Name: <INPUT TYPE=TEXT NAME="name" VALUE='$name'>\n"; echo 'Name: <INPUT TYPE=TEXT NAME="address" VALUE='$address'>\n"; echo 'Name: <INPUT TYPE=TEXT NAME="phone" VALUE='$phone'>\n"; } else { // Form is complete. [code to send form] } That way, as long as your error reporting isn't set too high (as to warn about uninitialized variables), it will print the form empty the first time, and if the user submits it without completing it, it will reprint the form with whatever data the user has provided. Please note-- this was a very short example (no submit button, no stripslashes() on the variables) but you get the idea. -----Original Message----- From: Kurth Bemis [mailto:kurth@usaexpress.net] Sent: Wednesday, August 08, 2001 2:36 PM To: php-general@lists.php.net Subject: [PHP] form validataion? i want to do form validation server side...not client side...... i'm wondering what programers use to validate form data.....if loops....arrays? what? ~kurth -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#61898) next »