-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresAdminAgregarLibro.php
More file actions
33 lines (26 loc) · 1.19 KB
/
resAdminAgregarLibro.php
File metadata and controls
33 lines (26 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
session_start();
if (!isset($_SESSION["id"]) or $_SESSION["rango"] == 2){
header("location: index.php");
exit(401);
}
require_once("privado/configDB.php");
if (strlen($_POST["titulo"]) > 1 && strlen($_POST["link"]) > 1 && strlen($_POST["fecha"]) > 1 && file_exists($_FILES["imagen"]["tmp_name"])){
$titulo = $base->real_escape_string(filter_input(INPUT_POST, "titulo"));
$link = $base->real_escape_string(filter_input(INPUT_POST, "link"));
$fecha = $base->real_escape_string(filter_input(INPUT_POST, "fecha"));
$nombreHash = md5_file($_FILES["imagen"]["tmp_name"]);
$pre = explode(".", $_FILES["imagen"]["name"]);
$extension = end($pre);
$dirImagen = "img/$nombreHash.$extension";
move_uploaded_file($_FILES["imagen"]["tmp_name"], $dirImagen);
$query = "INSERT INTO `libros`(`titulo`, `link_google`, `link_imagen`, `fecha`) VALUES ('$titulo','$link','$dirImagen','$fecha')";
$base->query($query);
$base->close();
// header("Location: http://localhost/Libreria/index.php");
echo "Libro agregado";
}
else{
echo "No se recibieron todos los datos!";
}
?>