Created
April 26, 2014 01:25
-
-
Save xombra/11309193 to your computer and use it in GitHub Desktop.
Validar email PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function VERIFICA_EMAIL($email){ | |
$email = strtolower(trim($email)); | |
$mail_correcto = 0; | |
if ((strlen($email) >= 6) && (substr_count($email,"@") == 1) && (substr($email,0,1) != "@") && (substr($email,strlen($email)-1,1) != "@")){ | |
if ((!strstr($email,"'")) && (!strstr($email,"\"")) && (!strstr($email,"\\")) && (!strstr($email,"\$")) && (!strstr($email," "))) { | |
if (substr_count($email,".")>= 1){ | |
$term_dom = substr(strrchr ($email, '.'),1); | |
if (strlen($term_dom)>1 && strlen($term_dom)<5 && (!strstr($term_dom,"@")) ){ | |
$antes_dom = substr($email,0,strlen($email) - strlen($term_dom) - 1); | |
$caracter_ult = substr($antes_dom,strlen($antes_dom)-1,1); | |
if ($caracter_ult != "@" && $caracter_ult != "."){ | |
return 1; | |
} | |
} | |
} | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment