Add files via upload

This commit is contained in:
adrireal 2021-04-12 17:25:15 +02:00 committed by GitHub
parent cc841917df
commit e2682476f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 17 deletions

View File

@ -2,8 +2,7 @@
session_start();
require_once('../assets/php/template.php');
require_once('../assets/php/user_dto.php');
require_once('../assets/php/user_dao.php');
require_once('./includes/user_dao.php');
$template = new Template();
@ -35,25 +34,35 @@
$this->id = "xxxx";
// Creamos objetos
//$instanceDAO = new userDAO();
//$uDTO = $instanceDAO->loadUser($this->id, $this->name, $this->email, $this->password, $this->rol);
$instanceDAO = new UserDAO('complucine');
$uDTO = $instanceDAO->loadUser($this->id, $this->name, $this->email, $this->password, $this->rol);
if($this->password == $this->repassword /*&& !$instanceDAO->selectUser($uDTO->getName())*/) { // Comprobacion de contrasenyas iguales y 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->getRoles());
$this->reply = "<h1>¡Éxito en el registro!</h1><hr/>
<p>{$_POST['name']}, te has registrado correctamente.</p>
<p>Puedes iniciar sesión en el siguiente enlace.</p>
<br>
<a href='./index.php'><button>Iniciar sesión</button></a>\n";
}
else {
$this->reply = "<h1>¡Ha ocurrido un error!</h1><hr />".
"<p>Los datos introducidos no son válidos o el usuario ya existe.</p>
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 = "<h1>¡Éxito en el registro!</h1><hr/>
<p>{$_POST['name']}, te has registrado correctamente.</p>
<p>Puedes iniciar sesión en el siguiente enlace.</p>
<br>
<a href='./index.php'><button>Iniciar sesión</button></a>\n";
}
else {
$this->reply = "<h1>¡Ha ocurrido un error!</h1><hr/>".
"<p>¡Ya existe un usuario con este nombre!</p>
<p>Vuelve a intetarlo o prueba a inicia sesión.</p>
<a href='./'><button>Iniciar Sesión</button></a>
<form method='post' action='./'><button name='register' id='register'>Registro</button></form>\n";
}
}
else {
$this->reply = "<h1>¡Ha ocurrido un error!</h1><hr/>".
"<p>Los datos introducidos no son válidos.</p>
<p>Vuelve a intetarlo o prueba a inicia sesión.</p>
<a href='./'><button>Iniciar Sesión</button></a>
<form method='post' action='./'><button name='register' id='register'>Registro</button></form>\n";
}
}