reply = array(); } //Methods: //Returns validation response: public function getReply() { if(isset($_SESSION["login"])){ $name = strtoupper($_SESSION['nombre']); $this->reply = "

Bienvenido {$_SESSION['nombre']}


{$name}, has creado tu cuenta de usuario correctamente.

Usa los botones para navegar

\n"; } else if(!isset($_SESSION["login"])){ $this->reply = "

ERROR


". "

Ha ocurrido un problema y no hemos podido completar el registro.

Vuelve a intetarlo o inicia sesión si tienes una cuenta de usuario.

\n"; } return $this->reply; } //Process form: public function processesForm($name, $mail, $pass, $repass) { $register = true; $name = $this->test_input($name); $mail = $this->test_input($mail); $pass = $this->test_input($pass); $repass = $this->test_input($repass); $username = isset($name) ? $name : null ; if (!$username) { $register = false; } $email = isset($mail) ? $mail : null ; if (!$email || !mb_ereg_match(self::HTML5_EMAIL_REGEXP, $email)) { $register = false; } $password = isset($pass) ? $pass : null ; $repassword = isset($repass) ? $repass : null ; if (!$password || mb_strlen($password) < 4) { $register = false; } if(!$repassword || mb_strlen($repassword) < 4){ $register = false; } if($password != $repassword){ $register = false; } if ($register) { $bd = new UserDAO('complucine'); if($bd){ try{ $this->user = $bd->selectUser($username, $password); if (!$this->user) { $bd->createUser("", $username, $email, $password, "user"); $this->user = $bd->selectUser($username, $password); if ($this->user) { $this->user->setPass(null); $_SESSION["user"] = serialize($this->user); $_SESSION["nombre"] = $this->user->getName(); $_SESSION["rol"] = $this->user->getRol(); $_SESSION["login"] = $register; } } else{ $_SESSION["login"] = false; } } catch (Exception $e){ $_SESSION["login"] = $register; } } } } protected function test_input($input){ return htmlspecialchars(trim(strip_tags($input))); } } ?>