diff --git a/assets/php/includes/user_dao.php b/assets/php/includes/user_dao.php index 14a492c..0396517 100644 --- a/assets/php/includes/user_dao.php +++ b/assets/php/includes/user_dao.php @@ -47,8 +47,8 @@ public function createUser($id, $username, $email, $password, $rol){ $password = $this->encryptPass($password); - $sql = sprintf( "INSERT INTO users( id, username, email, passwd, rol) - VALUES ( '%s', '%s', '%s', '%s', '%s')", + $sql = sprintf( "INSERT INTO users ( id, username, email, passwd, rol) + VALUES ( '%d', '%s', '%s', '%s', '%s')", $id, $username, $email, $password, $rol ); $resul = mysqli_query($this->mysqli, $sql); @@ -64,7 +64,6 @@ $sql = sprintf( "SELECT * FROM users WHERE username = '%s'", $username ); $resul = mysqli_query($this->mysqli, $sql); - $resul->data_seek(0); $user = null; while ($fila = $resul->fetch_assoc()) { if($username === $fila['username'] && $this->verifyPass($password, $fila['passwd'])){ @@ -72,8 +71,8 @@ } } - //mysqli_free_result($selectUser); - $resul->free(); + mysqli_free_result($resul); + //$resul->free(); return $user; } diff --git a/panel_user/includes/formUploadPic.php b/panel_user/includes/formUploadPic.php index 23085c4..928e948 100644 --- a/panel_user/includes/formUploadPic.php +++ b/panel_user/includes/formUploadPic.php @@ -54,7 +54,7 @@ class FormUploadFiles extends Form { $finfo = new \finfo(FILEINFO_MIME_TYPE); $mimeType = $finfo->file($_FILES['archivo']['tmp_name']); $ok = preg_match('/image\/*./', $mimeType); - finfo_close($finfo); + //finfo_close(); if ( $ok ) { $tmp_name = $_FILES['archivo']['tmp_name']; diff --git a/register/includes/formRegister.php b/register/includes/formRegister.php index 689ac6b..6f378f1 100644 --- a/register/includes/formRegister.php +++ b/register/includes/formRegister.php @@ -93,18 +93,23 @@ class FormRegister extends Form { if ($this->user->data_seek(0)) { $result[] = "El email ya está registrado."; } else { - $bd->createUser("", $nombre, $email, $password, "user"); - $this->user = $bd->selectUser($nombre, $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"] = true; - $img = "../img/users/user.jpg"; //USER_PICS - $profile_img = "../img/users/".$nombre.".jpg"; - copy($img, $profile_img); - $result = ROUTE_APP."register/register.php"; + if($bd->createUser("", $nombre, $email, $password, "user")){ + $this->user = $bd->selectUser($nombre, $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"] = true; + $img = "../img/users/user.jpg"; //USER_PICS + $profile_img = "../img/users/".$nombre.".jpg"; + copy($img, $profile_img); + $result = ROUTE_APP."register/register.php"; + } else { + $result[] = "Ha ocurrido un error al iniciar la sesión\nPero el usuario se creó correctamente."; + } + } else { + $result[] = "Ha ocurrido un error al crear el usuario."; } } }