Home >> Snippet List >> Snippet

Name
Validate email address #1
Description
Validates an email address format
PHP Snippet
<?PHP
 
$email = "someone@example.com";
IF(EREGI("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email)) {
  ECHO "Valid email address.";
}ELSE{
  ECHO "Invalid email address.";
}
 
?>