Validate Email Address of a User

Do you want to validate the email address given by the user manually…..use php for doing that….

its easy and simple to understand…..

Lets  start  now…

<?php
$email_a = “kmvkrish@gmail.com”; //declare a sample email address
$email_b =”kmvkrish@12 box.com”; //false email id

 if (filter_var($email_a, FILTER_VALIDATE_EMAIL)) {
echo “This ($email_a) email address is considered valid.”;
}
 if (filter_var($email_b, FILTER_VALIDATE_EMAIL)) {
echo “This ($email_b) email address is considered valid.”;
}
?>

In the above code….

filter_var($var, FLAG) is a function of the PHP library which checks each character  of the email address and if matched the pattern exactly returns TRUE else returns FALSE

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s