-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmyticket.php
180 lines (149 loc) · 6.72 KB
/
myticket.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<?php
include 'dbconnect.php';
include 'server.php';
if (!isset($_SESSION['cust_id']))
{
header("location: ../index.php");
}
else{ //Continue to current page
header( 'Content-Type: text/html; charset=utf-8' );
}
?>
<!DOCTYPE html>
<html dir="">
<head>
<title>Bus Reservation System</title>
<meta charset="utf-8">
<meta name="fragment" content="!">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link href="assets/css/index.css" type="text/css" rel="stylesheet" />
<link href="assets/css/seat.css" type="text/css" rel="stylesheet" />
<style>
form label {
width: 140px;
}
</style>
</head>
<body>
<?php
if (!isset($_SESSION['total_rent']))
{
header("location: index.php");
}
else{ //Continue to current page
header( 'Content-Type: text/html; charset=utf-8' );
}
?>
<div id="pagewrapper">
<div id="topbg"></div>
<div id="systemName">
<h1>Bus Booking</h1>
</div>
<div id="header">
<div id="mainmenu">
<header>
<ul>
<li><a href="index.php">Home</a></li>
<li><a href="timetable.php">Time Table</a></li>
<?php if (!isset($_SESSION['cust_name'])) {?>
<li><a href="login.php">Login</a></li>
<?php }?>
<?php if (isset($_SESSION['cust_name'])) {?>
<li> <a href="index.php?logout='1'">Logout</a> </li>
<?php }?>
</ul>
</header>
</div>
</div>
<div></div>
<div></div>
<div></div>
<div id="content">
<h1>My Tickets</h1>
<div class="content" style="text-align:center;">
<!-- notification message -->
<?php if (isset($_SESSION['booking_success'])) {?>
<div class="text success" >
<h3 style="color: green;">
<?php
echo $_SESSION['booking_success'];
unset($_SESSION['booking_success']);
?>
</h3>
</div>
<?php } ?>
</div>
<div class="busdataarea" style="margin: 20px 0 0; float:none; padding: 20px 10px;">
<table border="0" cellpadding="0" cellspacing="20" style="margin: 5px 0; position: relative; margin: 0 auto; width: auto;">
<thead style="text-align: left;">
<tr>
<th>Bus Name</th>
<th>From</th>
<th>To</th>
<th>Journey Date</th>
<th>Booking Date</th>
<th>Seat No.</th>
<th>Departure Time</th>
<th>Arrival Time</th>
<th>Total Fare</th>
</tr>
</thead>
<?php
$journeyFrom = $_SESSION['journeyFrom'];
$journeyTo = $_SESSION['journeyTo'];
$sql = "SELECT * from `time_table` WHERE departure_station = '$journeyFrom' AND arrival_station = '$journeyTo'";
$run = mysqli_query($db,$sql);
if(!$run)
die("Unable to run query".mysqli_error($db));
$no_rows = mysqli_num_rows($run);
if($no_rows>0){
while($data = mysqli_fetch_assoc($run)){
$departure_station = $data['departure_station'];
$arrival_station = $data['arrival_station'];
$dateOfJourney = $_SESSION['dateOfJourney'];
$selected_seat = $_SESSION['selected_seat'];
$booking_date = $_SESSION['booking_date'];
$total_rent = $_SESSION['total_rent'];
if(($journeyFrom == $departure_station) && ($journeyTo == $arrival_station)){
echo "<td>".$data['departure_station']."-".$data['arrival_station']."</td>";
echo "<td>".$data['departure_station']."</td>";
echo "<td>".$data['arrival_station']."</td>";
echo "<td>".$dateOfJourney."</td>";
echo "<td>".$booking_date."</td>";
echo "<td>".$selected_seat."</td>";
if(empty($data['departure_time'])){
$departure_time = "--:-- AM";
}else{
$departure_time = date('h:i A', strtotime($data['departure_time']));
}
echo "<td>".$departure_time."</td>";
if(empty($data['arrival_time'])){
$arrival_time = "--:-- PM";
}else{
$arrival_time = date('h:i A', strtotime($data['arrival_time']));
}
echo "<td>".$arrival_time."</td>";
echo "<td>".$total_rent."</td>";
}
else if(($journeyFrom != $departure_station) && ($journeyTo != $arrival_station)) {
echo ("No data available in table.");
$sql = "SELECT * from `time_table` WHERE departure_station = '$journeyFrom' AND arrival_station = '$journeyTo'";
$run = mysqli_query($db,$sql);}
}
}
else{
echo "<td colspan='5'> No data found </td> <br/>";
}
?>
</table>
</div>
</div>
<!--#contentwrapper-->
<div class="clear"></div>
<div id="footer">
Copyright © 2018.<br> All Rights Reserved.
</div>
</div>
</body>
</html>