Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. public function comprobarEmail($email){
  2. $mail_correcto = 0;
  3. //compruebo unas cosas primeras
  4. if ((strlen($email) >= 6) && (substr_count($email,"@") == 1) && (substr($email,0,1) != "@") && (substr($email,strlen($email)-1,1) != "@")){
  5. if ((!strstr($email,"'")) && (!strstr($email,"\"")) && (!strstr($email,"\\")) && (!strstr($email,"\$")) && (!strstr($email," "))) {
  6. //miro si tiene caracter .
  7. if (substr_count($email,".")>= 1){
  8. //obtengo la terminacion del dominio
  9. $term_dom = substr(strrchr ($email, '.'),1);
  10. //compruebo que la terminación del dominio sea correcta
  11. if (strlen($term_dom)>1 && strlen($term_dom)<5 && (!strstr($term_dom,"@")) ){
  12. //compruebo que lo de antes del dominio sea correcto
  13. $antes_dom = substr($email,0,strlen($email) - strlen($term_dom) - 1);
  14. $caracter_ult = substr($antes_dom,strlen($antes_dom)-1,1);
  15. if ($caracter_ult != "@" && $caracter_ult != "."){
  16. $mail_correcto = 1;
  17. }
  18. }
  19. }
  20. }
  21. }
  22. if ($mail_correcto)
  23. return 1;
  24. else
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement