name = $this->test_input($_POST["name"]); $this->email = $this->test_input($_POST["email"]); $this->password = $this->test_input($_POST["pass"]); $this->repassword = $this->test_input($_POST["repass"]); $this->rol = "user"; $this->id = "xxxx"; // Creamos DAO $instanceDAO = new UserDAO('complucine'); // Creamos DTO $uDTO = $instanceDAO->loadUser($this->id, $this->name, $this->email, $this->password, $this->rol); if($this->password == $this->repassword) { // Comprobacion de contrasenyas iguales $resultado = $instanceDAO->selectUser($uDTO->getName()); if($resultado->num_rows == 0) { // Comprobacion de que el usuario no existe ya en la BD // Se manda el usuario al DAO, que lo creara en la BD $instanceDAO->createUser($uDTO->getId(), $uDTO->getName(), $uDTO->getEmail(), $uDTO->getPass(), $uDTO->getRol()); $this->reply = "

¡Éxito en el registro!


{$_POST['name']}, te has registrado correctamente.

Puedes iniciar sesión en el siguiente enlace.


\n"; } else { $this->reply = "

¡Ha ocurrido un error!


". "

¡Ya existe un usuario con este nombre!

Vuelve a intetarlo o prueba a inicia sesión.

\n"; } $resultado->free(); } else { $this->reply = "

¡Ha ocurrido un error!


". "

Los datos introducidos no son válidos.

Vuelve a intetarlo o prueba a inicia sesión.

\n"; } } // Metodo auxiliar que comprueba la validez de los parametros private function test_input($input){ return htmlspecialchars(trim(strip_tags($input))); } public function getReply() { return $this->reply; } } ?>