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

Leave a comment