Skip to content

Instantly share code, notes, and snippets.

@xombra
Created April 26, 2014 01:25
Show Gist options
  • Save xombra/11309193 to your computer and use it in GitHub Desktop.
Save xombra/11309193 to your computer and use it in GitHub Desktop.
Validar email PHP
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