-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete_booking.php
49 lines (37 loc) · 1.59 KB
/
delete_booking.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
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
include('dbcon.php');
if (isset($_GET['id'])) {
$id = $_GET['id'];
// Delete the booking
$deleteBookingQuery = "DELETE FROM booking WHERE bookingID = '$id'";
$deleteBookingResult = mysqli_query($connection, $deleteBookingQuery);
if (!$deleteBookingResult) {
die("Booking deletion failed: " . mysqli_error($connection));
}
// Delete associated student
$deleteStudentQuery = "DELETE FROM student WHERE userID = '$id'";
$deleteStudentResult = mysqli_query($connection, $deleteStudentQuery);
if (!$deleteStudentResult) {
die("Student deletion failed: " . mysqli_error($connection));
}
// Delete associated user phones
$deleteUserPhonesQuery = "DELETE FROM userphones WHERE userID = '$id'";
$deleteUserPhonesResult = mysqli_query($connection, $deleteUserPhonesQuery);
if (!$deleteUserPhonesResult) {
die("User phones deletion failed: " . mysqli_error($connection));
}
// Delete associated room
$deleteRoomQuery = "DELETE FROM room WHERE userID = '$id'";
$deleteRoomResult = mysqli_query($connection, $deleteRoomQuery);
if (!$deleteRoomResult) {
die("Room deletion failed: " . mysqli_error($connection));
}
// Delete associated sensor readings
$deleteReadingsQuery = "DELETE FROM sensorreadings WHERE userID = '$id'";
$deleteReadingsResult = mysqli_query($connection, $deleteReadingsQuery);
if (!$deleteReadingsResult) {
die("Sensor readings deletion failed: " . mysqli_error($connection));
}
header('location:index.php?delete_msg=You have deleted the record.');
}
?>