Añadida LOGIN a través de BASE DE DATOS

Se ha creado la base de datos de usuarios y toda la lógica para iniciar sesión mediante ella.
This commit is contained in:
Fernando Méndez 2021-04-07 20:17:46 +02:00 committed by GitHub
parent 7e2ef23349
commit fad708b963
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -68,7 +68,6 @@ class FormLogin extends Form {
$bd = new UserDAO('complucine'); $bd = new UserDAO('complucine');
if($bd){ if($bd){
$selectUser = $bd->selectUser($username); $selectUser = $bd->selectUser($username);
$selectUser->data_seek(0); $selectUser->data_seek(0);
while ($fila = $selectUser->fetch_assoc()) { while ($fila = $selectUser->fetch_assoc()) {
if($username === $fila['username'] && $bd->verifyPass($password, $fila['passwd'])){ if($username === $fila['username'] && $bd->verifyPass($password, $fila['passwd'])){
@ -76,17 +75,23 @@ class FormLogin extends Form {
} }
} }
mysqli_free_result($selectUser); try{
//$selectUser->free(); if ($this->user) {
}
if ($this->user->getName()) {
$_SESSION['user'] = $this->user; $_SESSION['user'] = $this->user;
$_SESSION["nombre"] = $this->user->getName(); $_SESSION["nombre"] = $this->user->getName();
$_SESSION["login"] = $login; $_SESSION["login"] = $login;
$_SESSION["rol"] = $this->user->getRol(); $_SESSION["rol"] = $this->user->getRol();
} }
} }
catch (Exception $e){
$_SESSION["login"] = $login;
}
mysqli_free_result($selectUser);
//$selectUser->free();
}
}
} }