Add files via upload
This commit is contained in:
parent
258a7bfd05
commit
72b1bab936
@ -48,7 +48,7 @@
|
|||||||
$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,7 +93,7 @@ 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);
|
||||||
@ -105,6 +105,11 @@ class FormRegister extends Form {
|
|||||||
$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