-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfirmation.php
49 lines (45 loc) · 1.63 KB
/
confirmation.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
$servername = "localhost"; //variable
$username = "root"; //variable
$password = ""; //variable
$dbname = "online_bus_ticket"; //variable
$conn = new mysqli($servername, $username, $password, $dbname); //connect with database
if (isset($_POST['button_confirm_order'])) {
$name = $_POST['name'];
$address = $_POST['address'];
$phone = $_POST['phone'];
$leaving = $_POST['leaving'];
$departing = $_POST['departing'];
$gender = $_POST['gender'];
$get_selected_seats = $_COOKIE['cookie_selected_seats'];
$seats = explode (",", $get_selected_seats);
$y = $_COOKIE['cookie_bus_id'];
$z = 0;
for ($i=0; $i < count(array_filter($seats)); $i++, $z++) {
$query = "SELECT blocked FROM seat_plan WHERE bus_id = $y AND seat_id = $seats[$i]";
$result = mysqli_query($conn,$query);
$row = mysqli_fetch_assoc($result);
if ($row['blocked']=='Y') {
break;
}
}
if ($z == count($seats)) {
for ($i=0; $i < count($seats); $i++) {
$query = "UPDATE seat_plan SET blocked='Y', availibility='S' WHERE bus_id = $y AND seat_id = $seats[$i]";
$result = mysqli_query($conn,$query);
}
$mydate=getdate(date("U"));
session_start();
$_SESSION['pass_name'] = $name;
$_SESSION['pass_address'] = $address;
$_SESSION['phone'] = $phone;
$_SESSION['pass_leaving'] = $leaving;
$_SESSION['pass_departing'] = $departing;
$_SESSION['pass_gender'] = $gender;
$_SESSION['pass_issue_date'] = $mydate[mday] ." " . $mydate[month] .", " . $mydate[year] .$mydate[hours].$mydate[minutes];
header("Location:php/ticket.php");
exit();
}
}
$conn->close();
?>