-
Notifications
You must be signed in to change notification settings - Fork 0
/
Delete_Resto script.php
36 lines (32 loc) · 1010 Bytes
/
Delete_Resto script.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
36
<?php
//require_once('lib/database.php');
$servername = "localhost:3306";
$username = "root";
$password = "";
$dbname = "restaurant_final";
$tbl_name = "restaurant";
$tbl_name2 = "image";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
//Test connection
if (mysqli_connect_error()){
die('Connect Error ('. mysqli_connect_errno() .') '
. mysqli_connect_error());
}
else{
$id = $_GET['id']; //Get the Restaurant_ID from the link
$sql = "DELETE FROM $tbl_name WHERE Restaurant_ID='$id'"; //Store a DELETE query in a '$sql' variable.
$sql2 = "DELETE FROM $tbl_name2 WHERE Image_ID='$id'";
mysqli_query($conn, $sql2);
//Check if the query was well executed
if (mysqli_query($conn, $sql)) {
header('Location: Adminpage.php');
} else {
echo "Error: " . $sql . "" . mysqli_error($conn);
}
}
?>