diff --git a/panel_user/includes/formChangeEmail.php b/panel_user/includes/formChangeEmail.php index 5d83137..0ee1c96 100644 --- a/panel_user/includes/formChangeEmail.php +++ b/panel_user/includes/formChangeEmail.php @@ -3,6 +3,8 @@ require_once('../assets/php/form.php'); include_once('../assets/php/common/user.php'); class FormChangeEmail extends Form { + //Constants: + const HTML5_EMAIL_REGEXP = '^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$'; public function __construct() { $options = array("action" => "./?option=manage_profile"); @@ -44,9 +46,9 @@ class FormChangeEmail extends Form { protected function procesaFormulario($datos){ $result = array(); - $nombre = $datos['new_name'] ?? null; - if ( empty($nombre) || mb_strlen($nombre) < 5 ) { - $result['new_name'] = "El nombre tiene que tener una longitud de al menos 5 caracteres."; + $email = $datos['new_email'] ?? null; + if ( empty($email) || !mb_ereg_match(self::HTML5_EMAIL_REGEXP, $email) ) { + $result['new_email'] = "El nuevo email no es válido."; } $password = $datos['pass'] ?? null; @@ -64,13 +66,24 @@ class FormChangeEmail extends Form { if (!$user) { $result[] = "El usuario no existe."; } else { - $bd->changeUserName(unserialize($_SESSION['user'])->getId(), $username); + //$bd->changeUserName(unserialize($_SESSION['user'])->getId(), $username); $user = $bd->selectUser($username, $password); if (!$user){ - $result[] = "Ha ocurrido un probrema al actualizar el nombre de usuario."; + $result[] = "Ha ocurrido un probrema al actualizar el email de usuario."; }else{ $_SESSION['user'] = serialize($user); - $_SESSION["nombre"] = $user->getName(); + $_SESSION['message'] = "
+ "; $result = './?option=manage_profile'; } } diff --git a/panel_user/includes/formChangeName.php b/panel_user/includes/formChangeName.php index 756906c..d412084 100644 --- a/panel_user/includes/formChangeName.php +++ b/panel_user/includes/formChangeName.php @@ -44,8 +44,8 @@ class FormChangeName extends Form { $result = array(); $nombre = $datos['new_name'] ?? null; - if ( empty($nombre) || mb_strlen($nombre) < 5 ) { - $result['new_name'] = "El nombre tiene que tener una longitud de al menos 5 caracteres."; + if ( empty($nombre) || mb_strlen($nombre) < 4 ) { + $result['new_name'] = "El nombre tiene que tener una longitud de al menos 4 caracteres."; } $password = $datos['pass'] ?? null; @@ -54,7 +54,7 @@ class FormChangeName extends Form { } $password2 = $datos['repass'] ?? null; if ( empty($password2) || strcmp($password, $password2) !== 0 ) { - $result['repass'] = "Los passwords deben coincidir"; + $result['repass'] = "Los passwords deben coincidir."; } if (count($result) === 0) { @@ -70,6 +70,18 @@ class FormChangeName extends Form { }else{ $_SESSION['user'] = serialize($user); $_SESSION["nombre"] = $user->getName(); + $_SESSION['message'] = "