E-mail Validation with PHP


E-mail Validation with PHPThis tutorial will show you how to check to see if an E-mail address is valid. When you register on at a website, the site normally checks if the e-mail address that you enter is in a valid format. This is done by using what called a Regular Expression. What we need to do is check if a string (eg $email) matches the regular expression:

ereg(“^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]”, $email);

At the moment that only checks the string ($email), but does not does not output anything.So next we need to write an IF statement that returns a boolean value, if the string does not match the regular expressions.

if (eregi(“^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]”, $email))

Show Comments

Leave a Reply

Your email address will not be published. Required fields are marked *