Add files via upload
This commit is contained in:
parent
258a7bfd05
commit
72b1bab936
@ -47,8 +47,8 @@
|
|||||||
public function createUser($id, $username, $email, $password, $rol){
|
public function createUser($id, $username, $email, $password, $rol){
|
||||||
$password = $this->encryptPass($password);
|
$password = $this->encryptPass($password);
|
||||||
|
|
||||||
$sql = sprintf( "INSERT INTO users( id, username, email, passwd, rol)
|
$sql = sprintf( "INSERT INTO users ( id, username, email, passwd, rol)
|
||||||
VALUES ( '%s', '%s', '%s', '%s', '%s')",
|
VALUES ( '%d', '%s', '%s', '%s', '%s')",
|
||||||
$id, $username, $email, $password, $rol );
|
$id, $username, $email, $password, $rol );
|
||||||
|
|
||||||
$resul = mysqli_query($this->mysqli, $sql);
|
$resul = mysqli_query($this->mysqli, $sql);
|
||||||
@ -64,7 +64,6 @@
|
|||||||
$sql = sprintf( "SELECT * FROM users WHERE username = '%s'", $username );
|
$sql = sprintf( "SELECT * FROM users WHERE username = '%s'", $username );
|
||||||
$resul = mysqli_query($this->mysqli, $sql);
|
$resul = mysqli_query($this->mysqli, $sql);
|
||||||
|
|
||||||
$resul->data_seek(0);
|
|
||||||
$user = null;
|
$user = null;
|
||||||
while ($fila = $resul->fetch_assoc()) {
|
while ($fila = $resul->fetch_assoc()) {
|
||||||
if($username === $fila['username'] && $this->verifyPass($password, $fila['passwd'])){
|
if($username === $fila['username'] && $this->verifyPass($password, $fila['passwd'])){
|
||||||
@ -72,8 +71,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//mysqli_free_result($selectUser);
|
mysqli_free_result($resul);
|
||||||
$resul->free();
|
//$resul->free();
|
||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ class FormUploadFiles extends Form {
|
|||||||
$finfo = new \finfo(FILEINFO_MIME_TYPE);
|
$finfo = new \finfo(FILEINFO_MIME_TYPE);
|
||||||
$mimeType = $finfo->file($_FILES['archivo']['tmp_name']);
|
$mimeType = $finfo->file($_FILES['archivo']['tmp_name']);
|
||||||
$ok = preg_match('/image\/*./', $mimeType);
|
$ok = preg_match('/image\/*./', $mimeType);
|
||||||
finfo_close($finfo);
|
//finfo_close();
|
||||||
|
|
||||||
if ( $ok ) {
|
if ( $ok ) {
|
||||||
$tmp_name = $_FILES['archivo']['tmp_name'];
|
$tmp_name = $_FILES['archivo']['tmp_name'];
|
||||||
|
@ -93,18 +93,23 @@ class FormRegister extends Form {
|
|||||||
if ($this->user->data_seek(0)) {
|
if ($this->user->data_seek(0)) {
|
||||||
$result[] = "El email ya está registrado.";
|
$result[] = "El email ya está registrado.";
|
||||||
} else {
|
} else {
|
||||||
$bd->createUser("", $nombre, $email, $password, "user");
|
if($bd->createUser("", $nombre, $email, $password, "user")){
|
||||||
$this->user = $bd->selectUser($nombre, $password);
|
$this->user = $bd->selectUser($nombre, $password);
|
||||||
if ($this->user) {
|
if ($this->user) {
|
||||||
$this->user->setPass(null);
|
$this->user->setPass(null);
|
||||||
$_SESSION["user"] = serialize($this->user);
|
$_SESSION["user"] = serialize($this->user);
|
||||||
$_SESSION["nombre"] = $this->user->getName();
|
$_SESSION["nombre"] = $this->user->getName();
|
||||||
$_SESSION["rol"] = $this->user->getRol();
|
$_SESSION["rol"] = $this->user->getRol();
|
||||||
$_SESSION["login"] = true;
|
$_SESSION["login"] = true;
|
||||||
$img = "../img/users/user.jpg"; //USER_PICS
|
$img = "../img/users/user.jpg"; //USER_PICS
|
||||||
$profile_img = "../img/users/".$nombre.".jpg";
|
$profile_img = "../img/users/".$nombre.".jpg";
|
||||||
copy($img, $profile_img);
|
copy($img, $profile_img);
|
||||||
$result = ROUTE_APP."register/register.php";
|
$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.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user