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:[EMAIL PROTECTED]] 
Sent: Wednesday, August 08, 2001 2:36 PM
To: [EMAIL PROTECTED]
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED] To
contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to