-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcancel.php
More file actions
33 lines (26 loc) · 765 Bytes
/
Copy pathcancel.php
File metadata and controls
33 lines (26 loc) · 765 Bytes
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['passenger_id'])){
header("Location: login.html");
exit();
}
$conn = mysqli_connect('localhost','root','','btrs');
if(!$conn){
die("connection failed");
}
$ticket = $_GET['ticket_id'];
$passenger = $_SESSION['passenger_id'];
/* Check ticket belongs to this user */
$check = "SELECT * FROM ticket
WHERE ticket_id = $ticket
AND passenger_id = $passenger";
$result = mysqli_query($conn, $check);
if(mysqli_num_rows($result) == 0){
echo "This ticket does not belong to you or doesn't exist!";
exit();
}
/* Cancel only their own ticket */
$del = "UPDATE ticket SET status='cancel' WHERE ticket_id = $ticket";
mysqli_query($conn, $del);
echo "Ticket cancelled successfully!";
?>