Skip to content

Instantly share code, notes, and snippets.

@nirendra
Created November 27, 2013 23:48
Show Gist options
  • Save nirendra/7685056 to your computer and use it in GitHub Desktop.
Save nirendra/7685056 to your computer and use it in GitHub Desktop.
Email validation snippet in PHP
$email = $_POST['email'];
if(preg_match("~([a-zA-Z0-9!#$%&'*+-/=?^_`{|}~])@([a-zA-Z0-9-]).([a-zA-Z0-9]{2,4})~",$email)) {
echo 'This is a valid email.';
} else{
echo 'This is an invalid email.';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment