-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodifica_arancino.php
executable file
·36 lines (34 loc) · 1.15 KB
/
modifica_arancino.php
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
34
35
<?php
session_start();
//file upload
$target_dir = "images/";
$target_file = $target_dir . basename($_FILES["immagine"]["name"]);
$nomefile = basename($_FILES["immagine"]["name"]); //da inserire nel db
// Check if image file is a actual image or fake image
if(isset($_POST["submit"])) {
$check = getimagesize($_FILES["immagine"]["tmp_name"]);
if($check !== false) {
echo "File is an image - " . $check["mime"] . ".";
$uploadOk = 1;
} else {
echo "File is not an image.";
$uploadOk = 0;
}
}
move_uploaded_file($_FILES["immagine"]["tmp_name"], $target_file); //upload del file
//collegamento al db
$servername = "localhost";
$username = "root";
$password = "mysql";
$dbname = "progetto";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql='UPDATE arancini SET prezzo="'.$_POST['prezzo'].'", descrizione="'.$_POST['descrizione'].'", immagine="'.$nomefile.'" WHERE gusto="'.$_POST['gusto'].'"';
$conn->query($sql);
header('Location: admin_page.php?q=arancino_modificato');
exit();
?>