-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcancel_booking.php
More file actions
49 lines (36 loc) · 1.19 KB
/
Copy pathcancel_booking.php
File metadata and controls
49 lines (36 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
session_start();
// Check if the user is logged in
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
exit();
}
// Check if booking_id is provided
if (!isset($_GET['booking_id'])) {
header("Location: member_view_events.php");
exit();
}
$booking_id = $_GET['booking_id'];
// Database connection
$servername = "localhost";
$username = "root"; // Replace with your database username
$password = ""; // Replace with your database password
$dbname = "zoo_website";
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Delete the specific booking
$sql = "DELETE FROM bookings WHERE booking_id = ? AND user_id = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("si", $booking_id, $_SESSION['user_id']);
$stmt->execute();
$stmt->close();
// Optionally, you can update the event's availability here to increase the number of available tickets
$conn->close();
// Redirect back to "My Events" page with a success message or directly
header("Location: member_view_events.php?cancellation_success=1");
exit();
echo "Deleting booking with ID: " . $booking_id;
?>