Ver Mensaje Individual
  #1 (permalink)  
Antiguo 30/08/2008, 15:59
ggermes
 
Fecha de Ingreso: julio-2003
Mensajes: 52
Antigüedad: 20 años, 9 meses
Puntos: 0
Exclamación Validacion de mail con php ¿que hice mal?

Hola, estoy intentando validar el mail con php y no se porque la funcion de validacion me devuelve un valor vacio...no me funciona...aca les pego esa parte del codigo a ver si me pueden ayudar. Gracias!

Código:
$email = $_REQUEST['email'];
$notas = $_REQUEST['notas'];
$repemail = $_REQUEST['repemail'];
$repmatricula = $_REQUEST['repmatricula'];
//*************************************************
//Funcion Verficar formato del correo post insert
//*************************************************
function comprobar_email($email){
    $mail_correcto = 0;
    //compruebo unas cosas primeras
    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," "))) {
          //miro si tiene caracter .
          if (substr_count($email,".")>= 1){
             //obtengo la terminacion del dominio
             $term_dom = substr(strrchr ($email, '.'),1);
             //compruebo que la terminación del dominio sea correcta
             if (strlen($term_dom)>1 && strlen($term_dom)<5 && (!strstr($term_dom,"@")) ){
                //compruebo que lo de antes del dominio sea correcto
                $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 != "."){
                   $mail_correcto = 1;
                }
             }
          }
       }
    }
    if ($mail_correcto)
       return 1;
    else
       return 0;
}
$mailc="$mail_correcto";
//*************************************************
//*************************************************
//validacion de data post insert
//*************************************************
if($_REQUEST['nombre']==NULL) { echo "<script>alert('DEBE ESCRIBIR SU NOMBRE') | history.back()</script>"; mysql_close($con);}
elseif($_REQUEST['matricula']==NULL) { mysql_close($con); echo "<script>alert('DEBE ESCRIBIR SU MATRICULA') | history.back()</script>"; }
elseif($_REQUEST['periodo']==NULL) { mysql_close($con); echo "<script>alert('DEBE ESCRIBIR EL PERIODO EN EL CUAL HIZO EL CURSO') | history.back()</script>"; }
elseif($_REQUEST['fecha_r']==NULL) { mysql_close($con); echo "<script>alert('DEBE ESCRIBIR LA FECHA EN QUE TOMO LA DOCENCIA DEL CURSO') | history.back()</script>"; }
elseif($_REQUEST['titulo']==NULL) { mysql_close($con); echo "<script>alert('DEBE ESCRIBIR EL TITULO DEL CURSO REALIZADO') | history.back()</script>"; }
elseif($_REQUEST['profesor']==NULL) { mysql_close($con); echo "<script>alert('DEBE ESCRIBIR QUIEN FUE SU PROFESOR') | history.back()</script>"; }
elseif($_REQUEST['email']==NULL) { mysql_close($con); echo "<script>alert('DEBE ESCRIBIR SU CORREO ELECTRONICO') | history.back()</script>"; }
elseif($_REQUEST['email']!==$_REQUEST['repemail']) { mysql_close($con); echo "<script>alert('POR FAVOR VERIFIQUE EL CORREO ELECTRONICO') | history.back()</script>"; }
elseif($_REQUEST['matricula']!==$_REQUEST['repmatricula']) { mysql_close($con); echo "<script>alert('POR FAVOR VERIFIQUE EL NUMERO DE MATRICULA') | history.back()</script>"; }
elseif($mailc != "1") { mysql_close($con); echo "<script>alert('CORREO ELECTRONICO NO VALIDO') | history.back()</script>"; }

else {
//*************************************************
//insert
//*************************************************

mysql_query("INSERT INTO