Check if a string is an email address in PHP

if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
    echo 'This is a valid email address.';
    echo filter_var($email, FILTER_VALIDATE_EMAIL);
    // exit("E-mail is not valid");
}
else {
    echo 'Invalid email address.';
} 

This is not a great method and doesn't check if the email exists but it checks if it looks like an email with the @ and domain extension.

function checkEmail($email) {
   $find1 = strpos($email, '@');
   $find2 = strpos($email, '.');
   return ($find1 !== false && $find2 !== false && $find2 > $find1);
}

$email = '[email protected]';
if ( checkEmail($email) ) {
   echo $email . ' looks like a valid email address.';
}

Without regular expressions:

<?php
    if(filter_var("[email protected]", FILTER_VALIDATE_EMAIL)) {
        // valid address
    }
    else {
        // invalid address
    }
?>

The simplest approach is to use a regular expression to check email addresses, although there's some disagreement about how accurate this can be. This process is discussed in detail here:

Using a regular expression to validate an email address

You can use REGEXP in MySQL to select from the database based on your regular expression:

http://dev.mysql.com/doc/refman/5.1/en/regexp.html