FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Form validation

 


PatTheGreat42
I recently scripted a web form in PHP and, of course, included some form validation. One of the things I did was check the email to see if it included the "@" sign. However, the only way I could figure out how to do it was to use "strstr($_POST['email'],"@")," and see if it returns anything. If the return is FALSE, I know that they didn't include an @ sign. It works just peachy, but is there a better way to do this?
mathiaus
I use this
Code:
if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$_POST['email'])){
<<<ERROR>>>
} else {
<<REST OF FORM VALIDATION>>
}

This checks the @ symbol was used, a domain was given and no invalid characters are used.

The best way to validate an email is to create an account though, send an email with a link which actives that account.
dandelion
See also: Check email format.
Grimboy
On the other hand you have email validation to properly verify this and regex is slow and hard to read.
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.