Re: validating fields

From: Date: Fri, 09 Mar 2001 06:02:59 +0000
Subject: Re: validating fields
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-43116@lists.php.net to get a copy of this message
Consider seperating the checks and tell the user what they did and didn't do correctly as that way you can put the incorrect fields in bold and red fonts! Users LOVE that. And little custom messages like "Yo, your email of $email is incorrect and what kind of first name is $firstname?!" And maybe even tell them "You answered 85% of the fields correctly, all you have are 15% more to go!" Ahem. Something like that :) (hint: like an array to hold errors and if errors is_array then share this unfortunate news with the user, in a creative and useful manner.) Regards, Philip On Fri, 9 Mar 2001, Simon Garner wrote: > From: "W.D." <suedeuno@yahoo.com> > > > Actually I tried a variation of what you gave me before and it didnt work. > I > > couldnt get yours to validate thanks. heres what I used > > <?php > > if (getenv("REQUEST_METHOD") == "POST") > > { > > if ( > > eregi("^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,3}$", $Email) > > && eregi("^[a-z0-9]$", $FirstName) > > && eregi("^[a-z0-9]$", $LastName) > > ) > > { > > echo "thanks"; > > } > > else > > { > > echo "error!"; > > } > > } > > ?> > > > > This is directly after the form using the registered vars $Email, > > $FirstName, $LastName. So I dunno whats wrong.. > > > > > Your regular expressions are incorrect. > > Try: > > if ( > eregi("^[a-z0-9\._-]+@[a-z0-9\.-]+\.[a-z]{2,3}$", $Email) > && eregi("^[a-z0-9]+$", $FirstName) > && eregi("^[a-z0-9]+$", $LastName) > ) > > > Cheers > > Simon Garner > > > -- > 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 (#43116) next »