Foros del Web » Programando para Internet » PHP »

Ajustes => Email

Estas en el tema de Ajustes => Email en el foro de PHP en Foros del Web. EN LOS AJUSTES EN EMAIL, HAY UN PROBLEMA QUE NOSE PORQUE LES DEJO EL CODIGO: EL PROBLEMA ES QUE AL CAMBIAR EMAIL SALE : ¡Los ...
  #1 (permalink)  
Antiguo 07/03/2014, 11:51
 
Fecha de Ingreso: febrero-2014
Mensajes: 31
Antigüedad: 10 años, 3 meses
Puntos: 0
Ajustes => Email

EN LOS AJUSTES EN EMAIL, HAY UN PROBLEMA QUE NOSE PORQUE LES DEJO EL CODIGO:

EL PROBLEMA ES QUE AL CAMBIAR EMAIL SALE : ¡Los datos son incorrectos!
CUANDO LOS DATOS SON BUENOS, Y NO SE CAMBIA, NOSE PORQUE, NECESITO AYUDA.

Código PHP:
if(isset($_POST['save'])){
    
$pass1 FilterText($_POST['password']);
    
$pass1_hash HoloHashMD5($pass1$myrow['username']);
    
$day1 FilterText($_POST['day']);
    
$month1 FilterText($_POST['month']);
    
$year1 FilterText($_POST['year']);
        
$formatted_dob "".$day1.".".$month1.".".$year1."";
    
$mail1 FilterText($_POST['email']);
    
$themail $mail1;
        
//checks password --encryption--
        
if($pass1_hash == $myrow['password'] && $formatted_dob == $myrow['birth']){
        
$email_check preg_match("/^[a-z0-9_\.-]+@([a-z0-9]+([\-]+[a-z0-9]+)*\.)+[a-z]{2,7}$/i"$mail1);
            if(
$email_check == "1"){
            
mysql_query("UPDATE users SET mail = '".$mail1."' WHERE username = '".$rawname."' and password = '".$rawpass."'");

            
$result "Tu email se ha cambiado con éxito a \"".$mail1."\".";
            } else {
            
$result "Dirección de correo electrónico incorrecto.";
            
$error "1";
            }
        } else {
        
$result "¡Los datos son incorrectos!";
        
$error "1";
        }
    } else {
    
$themail $myrow['mail'];
    } 
  #2 (permalink)  
Antiguo 07/03/2014, 12:13
Avatar de hhs
hhs
Colaborador
 
Fecha de Ingreso: junio-2013
Ubicación: México
Mensajes: 2.995
Antigüedad: 10 años, 10 meses
Puntos: 379
Respuesta: Ajustes => Email

Cita:
Iniciado por davidprogramacion Ver Mensaje
EN LOS AJUSTES EN EMAIL, HAY UN PROBLEMA QUE NOSE PORQUE LES DEJO EL CODIGO:

EL PROBLEMA ES QUE AL CAMBIAR EMAIL SALE : ¡Los datos son incorrectos!
CUANDO LOS DATOS SON BUENOS, Y NO SE CAMBIA, NOSE PORQUE, NECESITO AYUDA.

Código PHP:
if(isset($_POST['save'])){
    
$pass1 FilterText($_POST['password']);
    
$pass1_hash HoloHashMD5($pass1$myrow['username']);
    
$day1 FilterText($_POST['day']);
    
$month1 FilterText($_POST['month']);
    
$year1 FilterText($_POST['year']);
        
$formatted_dob "".$day1.".".$month1.".".$year1."";
    
$mail1 FilterText($_POST['email']);
    
$themail $mail1;
        
//checks password --encryption--
        
if($pass1_hash == $myrow['password'] && $formatted_dob == $myrow['birth']){
        
$email_check preg_match("/^[a-z0-9_\.-]+@([a-z0-9]+([\-]+[a-z0-9]+)*\.)+[a-z]{2,7}$/i"$mail1);
            if(
$email_check == "1"){
            
mysql_query("UPDATE users SET mail = '".$mail1."' WHERE username = '".$rawname."' and password = '".$rawpass."'");

            
$result "Tu email se ha cambiado con éxito a \"".$mail1."\".";
            } else {
            
$result "Dirección de correo electrónico incorrecto.";
            
$error "1";
            }
        } else {
        
$result "¡Los datos son incorrectos!";
        
$error "1";
        }
    } else {
    
$themail $myrow['mail'];
    } 
No seria mas sencillo usar filter_var: http://www.php.net/manual/en/function.filter-var.php
Código PHP:
Ver original
  1. if(filter_var($email, FILTER_VALIDATE_EMAIL) !== false){
  2.     echo 'correcto';
  3. }else{
  4.     echo 'problemas';  
  5. }
__________________
Saludos
About me
Laraveles
A class should have only one reason to change.

Etiquetas: email, mysql
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 09:46.