-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.php
More file actions
454 lines (440 loc) · 15.7 KB
/
action.php
File metadata and controls
454 lines (440 loc) · 15.7 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
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
<?php
$con=mysqli_connect('localhost','root','','transport');
session_start();
if (isset($_POST['alogin'])) {
$name=$_POST['uname'];
$psw=$_POST['psw'];
$sql="SELECT * FROM admin WHERE name='$name'AND psw='$psw'";
$run=mysqli_query($con,$sql);
if (mysqli_num_rows($run)==1) {
$_SESSION['aname']=$name;
header('location:../admin.php');
}
}
if (isset($_POST['signup'])) {
$name=$_POST['name'];
$uname=$_POST['uname'];
$age=$_POST['age'];
$pno=$_POST['pno'];
$aidno=$_POST['aidno'];
$psw=$_POST['psw'];
$email=$_POST['email'];
$sql="SELECT * FROM user_info WHERE uname='$uname'";
$run=mysqli_query($con,$sql);
if (mysqli_num_rows($run)>0) {
echo "<h4>USERNAME ALREADY EXIST PLEASE ENTER VALID USERNAME</h4>";
}else{
$sql="INSERT INTO `user_info` (`uid`, `name`, `uname`, `age`, `adhar_no`, `psw`, `email`)
VALUES (NULL, '$name', '$uname', '$age', '$aidno', '$psw', '$email')";
$run=mysqli_query($con,$sql);
if($run){
$_SESSION['uid']=mysqli_insert_id($con);
$_SESSION['uname']=$uname;
header('location:login.php');
}
}
}
if (isset($_POST['login'])) {
$name=$_POST['uname'];
$psw=$_POST['psw'];
$sql="SELECT * FROM user_info WHERE uname='$name'AND psw='$psw'";
$run=mysqli_query($con,$sql);
$row=mysqli_fetch_array($run);
if (mysqli_num_rows($run)==1) {
$_SESSION['uid']=$row['uid'];
$_SESSION['uname']=$name;
header('location:../profile.php');
}
}
if (isset($_POST['bus'])) {
$bname=$_POST['bname'];
$bno=$_POST['bno'];
$from=$_POST['from'];
$to=$_POST['to'];
$time=$_POST['time'];
$seat=$_POST['sno'];
$type=$_POST['rad'];
$fare=$_POST['fare'];
$sql="SELECT * FROM bus_details WHERE bno='$bno'AND bfrom='$from'";
$run=mysqli_query($con,$sql);
if (mysqli_num_rows($run)>0) {
echo "<h4>BUS DETAILS ALREADY EXIST PLEASE ENTER VALID DETAILS.... THANKS</h4>";
}else{
$sql="INSERT INTO `bus_details` (`bus_id`, `bname`, `bno`, `bfrom`, `bto`, `time`, `type`, `no_seat` ,`fare`)
VALUES (NULL, '$bname', '$bno', '$from', '$to','$time', '$type', '$seat' ,'$fare')";
$run=mysqli_query($con,$sql);
if ($run) {
header('location:../admin.php');
}
}
}
if (isset($_POST['search'])) {
$from=$_POST['from'];
$to=$_POST['to'];
$date=$_POST['date'];
$sql="SELECT * FROM booking_det WHERE jdate='$date'AND bfrom='$from'AND bto='$to'AND vacant>0";
$run=mysqli_query($con,$sql);
if (mysqli_num_rows($run)>0) {
while ($row=mysqli_fetch_array($run)) {
$bus_id=$row['bus_id'];
$vacant=$row['vacant'];
$sql1="SELECT * FROM bus_details WHERE bus_id='$bus_id'";
$run1=mysqli_query($con,$sql1);
$rows=mysqli_fetch_array($run1);
$bname=$rows['bname'];
$bno=$rows['bno'];
$time=$rows['time'];
$type=$rows['type'];
$fare=$rows['fare'];
echo " <div class='card'>
<div class='card-header bg-info'>
<h3 class='text-center'>$bname</h3>
</div>
<div class='card-body bg-dark'>
<div class='row'>
<div class='col-md-6'>
<h5>Bus NO. :</h5>
<h5>From :</h5>
<h5>To :</h5>
<h5>Time :</h5>
<h5>Bus Type :</h5>
<h5>Fare :</h5>
<h5>Seat available :</h5>
</div>
<div class='col-md-6'>
<h5>$bno</h5>
<h5>$from</h5>
<h5>$to</h5>
<h5>$time</h5>
<h5>$type</h5>
<h5>$fare</h5>
<h5>$vacant</h5>
</div>
</div>
</div>
<div class='card-footer bg-danger'>
<div class='btn btn-outline-light book' bid='$bus_id' jid='$date' seat='$vacant'>Book ticket</div>
</div>
</div>";
}
}else{
$sql="SELECT * FROM bus_details WHERE bfrom='$from'AND bto='$to'";
$run=mysqli_query($con,$sql);
if (mysqli_num_rows($run)>0) {
while ($row=mysqli_fetch_array($run)) {
$bus_id=$row['bus_id'];
$bname=$row['bname'];
$bno=$row['bno'];
$time=$row['time'];
$type=$row['type'];
$fare=$row['fare'];
$seat=$row['no_seat'];
echo "<div class='card'>
<div class='card-header bg-info'>
<h3 class='text-center'>$bname</h3>
</div>
<div class='card-body bg-dark'>
<div class='row'>
<div class='col-md-6'>
<h5>Bus NO. :</h5>
<h5>From :</h5>
<h5>To :</h5>
<h5>Time :</h5>
<h5>Bus Type :</h5>
<h5>Fare :</h5>
<h5>Seat available :</h5>
</div>
<div class='col-md-6'>
<h5>$bno</h5>
<h5>$from</h5>
<h5>$to</h5>
<h5>$time</h5>
<h5>$type</h5>
<h5>$fare</h5>
<h5>$seat</h5>
</div>
</div>
</div>
<div class='card-footer bg-danger'>
<div class='btn btn-outline-light book' bid='$bus_id' jid='$date' seat='$seat'>Book ticket</div>
</div>
</div>";
}
}else{
echo "<h1 class='text-dark text-center'>OOps no bus found</h1>";
}
}
}
if (isset($_POST['book'])) {
$jid=$_POST['jid'];
$bid=$_POST['bid'];
$seat=$_POST['seat'];
echo " <div class='signup-content'>
<form id='signup-form' class='signup-form'>
<h2>Booking Detail </h2>
<div class='form-group'>
<input type='text' class='form-input' id='name' placeholder='Passenger Name' required />
</div>
<div class='form-group'>
<input type='number' class='form-input' id='no' placeholder='Number of passenger' required />
</div>
<div class='form-group'>
<a href='#s' class='btn btn-success booking' bid='$bid' jid='$jid' seat='$seat'>Conform Booking</a>
</div>
</form>
</div>";
}
if (isset($_POST['booking'])) {
$jid=$_POST['jid'];
$bid=$_POST['bid'];
$seat=$_POST['seat'];
$name=$_POST['name'];
$no_p=$_POST['no_p'];
$uid=$_SESSION['uid'];
$date=date("Y-m-d");
$vacant=$seat-$no_p;
$sql="SELECT * FROM booking_det WHERE bus_id='$bid'AND jdate='$jid'";
$run=mysqli_query($con,$sql);
if (mysqli_num_rows($run)>0) {
$sql="UPDATE booking_det SET vacant='$vacant' WHERE bus_id='$bid'AND jdate='$jid'";
$run=mysqli_query($con,$sql);
if ($run) {
$sql="SELECT * FROM bus_details WHERE bus_id='$bid'";
$run=mysqli_query($con,$sql);
$row=mysqli_fetch_array($run);
$tseat=$row['no_seat'];
$seatno=$tseat-$seat;
$tseatno="";
for ($i=0; $i <$no_p; $i++) {
++$seatno;
$tseatno=$tseatno." ".$seatno;
}
$sql="SELECT * FROM ticket WHERE uid='$uid'AND pname='$name'AND jdate='$jid' AND bus_id='$bid' ";
$run=mysqli_query($con,$sql);
if (mysqli_num_rows($run)>0) {
echo "Your ticket is ALREADY booked please your ticket";
}else{
$sql="INSERT INTO `ticket` (`tid`, `bus_id`, `uid`, `seat_no`, `no_seat`, `ticket_status`, `jdate`, `booking_date`, `pname`) VALUES (NULL, '$bid', '$uid', '$tseatno', '$no_p', 'Conform', '$jid', '$date', '$name')";
$run=mysqli_query($con,$sql);
if ($run) {
echo "Your Ticket is Conformed .....Thank you";
}
}
}
}else{
$sql="SELECT * FROM bus_details WHERE bus_id='$bid'";
$run=mysqli_query($con,$sql);
$row=mysqli_fetch_array($run);
$tseat=$row['no_seat'];
$from=$row['bfrom'];
$to=$row['bto'];
$sql="INSERT INTO `booking_det` (`bus_id`, `vacant`, `jdate`, `bfrom`, `bto`)
VALUES ('$bid', '$vacant', '$jid', '$from', '$to')";
$run=mysqli_query($con,$sql);
if ($run) {
$seatno=$tseat-$seat;
$tseatno="";
for ($i=0; $i <$no_p; $i++) {
++$seatno;
$tseatno=$tseatno." ".$seatno;
}
$sql="SELECT * FROM ticket WHERE uid='$uid'AND pname='$name'AND jdate='$jid' AND bus_id='$bid' ";
$run=mysqli_query($con,$sql);
if (mysqli_num_rows($run)>0) {
echo "Your ticket is ALREADY booked please your ticket";
}else{
$sql="INSERT INTO `ticket` (`tid`, `bus_id`, `uid`, `seat_no`, `no_seat`, `ticket_status`, `jdate`, `booking_date`, `pname`) VALUES (NULL, '$bid', '$uid', '$tseatno', '$no_p', 'Conform', '$jid', '$date', '$name')";
$run=mysqli_query($con,$sql);
if ($run) {
echo "Your Ticket is Conformed .....Thank you";
}
}
}
}
}
if (isset($_POST['ticket'])) {
$uid=$_SESSION['uid'];
$sql="SELECT * FROM ticket WHERE uid='$uid'";
$run=mysqli_query($con,$sql);
if (mysqli_num_rows($run)==0) {
echo "<h4>First Book the ticket</h4>";
}else{
while ($row=mysqli_fetch_array($run)) {
$bid=$row['bus_id'];
$uid=$row['uid'];
$seat_no=$row['seat_no'];
$no_seat=$row['no_seat'];
$ticket_status=$row['ticket_status'];
$jdate=$row['jdate'];
$booking_date=$row['booking_date'];
$pname=$row['pname'];
$sql1="SELECT * FROM user_info WHERE uid='$uid' ";
$run1=mysqli_query($con,$sql1);
$rows=mysqli_fetch_array($run1);
$age=$rows['age'];
$adhar_no=$rows['adhar_no'];
$email=$rows['email'];
$sql2="SELECT * FROM bus_details WHERE bus_id='$bid'";
$run2=mysqli_query($con,$sql2);
$row1=mysqli_fetch_array($run2);
$bname=$row1['bname'];
$bno=$row1['bno'];
$bfrom=$row1['bfrom'];
$bto=$row1['bto'];
$time=$row1['time'];
$fare=$row1['fare'];
$Tfare=$fare*$no_seat;
echo "<div class='card'>
<div class='card-header bg-info'>
<h3 class='text-center'>Ticket Detail</h3>
</div>
<div class='card-body bg-dark'>
<div class='card bg-dark '>
<h2 class='text-center text-white'>Passenger Detail</h2><hr>
<div class='row'>
<div class='col-md-6'>
<h4 class=' text-white'>Passenger Name :</h4>
<h4 class='text-white'>Adhar Card No :</h4>
<h4 class='text-white'>Age :</h4>
<h4 class='text-white'>Email :</h4>
</div>
<div class='col-md-6'>
<h4 class=' text-white'>$pname </h4>
<h4 class='text-white'>$adhar_no </h4>
<h4 class='text-white'>$age</h4>
<h4 class='text-white'>$email</h4>
</div>
</div>
</div>
<div class='card bg-dark '>
<h2 class='text-center text-white'>Bus Detail</h2><hr>
<div class='row'>
<div class='col-md-6'>
<h4 class=' text-white'>Bus Name :</h4>
<h4 class='text-white'>Bus No :</h4>
<h4 class='text-white'>Time :</h4>
<h4 class='text-white'>From :</h4>
<h4 class='text-white'>To :</h4>
</div>
<div class='col-md-6'>
<h4 class=' text-white'>$bname</h4>
<h4 class='text-white'>$bno</h4>
<h4 class='text-white'>$time</h4>
<h4 class='text-white'>$bfrom</h4>
<h4 class='text-white'>$bto</h4>
</div>
</div>
</div>
<div class='card bg-dark '>
<h2 class='text-center text-white'>Ticket Detail</h2><hr>
<div class='row'>
<div class='col-md-6'>
<h4 class=' text-white'>Number Of Seat :</h4>
<h4 class='text-white'>Seat No :</h4>
<h4 class='text-white'>Status :</h4>
<h4 class='text-white'>Fare :</h4>
<h4 class='text-white'>Journey Date :</h4>
<h4 class='text-white'>Booking Date :</h4>
</div>
<div class='col-md-6'>
<h4 class=' text-white'>$no_seat</h4>
<h4 class='text-white'>$seat_no</h4>
<h4 class='text-white'>$ticket_status</h4>
<h4 class='text-white'>$Tfare</h4>
<h4 class='text-white'>$jdate</h4>
<h4 class='text-white'>$booking_date</h4>
</div>
</div>
</div>
</div>
<div class='card-footer bg-info'>
<a href='profile.php' class='btn btn-outline-danger'>Home</a>
</div>
</div>";
}
}
}
if (isset($_POST['bkd'])) {
$bid=$_POST['bid'];
$sql2="SELECT * FROM bus_details WHERE bus_id='$bid'";
$run2=mysqli_query($con,$sql2);
$row1=mysqli_fetch_array($run2);
$bname=$row1['bname'];
$seat=$row1['no_seat'];
$time=$row1['time'];
$sql="SELECT * FROM booking_det WHERE bus_id='$bid' ";
$run=mysqli_query($con,$sql);
if (mysqli_num_rows($run)==0) {
echo "<h4 class='text-center text-white'>Result Not Found</h4>";
}else{
$row=mysqli_fetch_array($run);
$vacant=$row['vacant'];
$booked=$seat-$vacant;
$jdate=$row['jdate'];
$bfrom=$row['bfrom'];
$bto=$row['bto'];
echo " <div class='row'>
<div class='col-md-2'>
<h3 class='text-center text-white'> $bname</h3>
</div>
<div class='col-md-2'>
<h3 class='text-center text-white'>$booked</h3>
</div>
<div class='col-md-2'>
<h3 class='text-center text-white'>$vacant</h3>
</div>
<div class='col-md-2'>
<h3 class='text-center text-white'>$bfrom</h3>
</div>
<div class='col-md-2'>
<h3 class='text-center text-white'>$bto</h3>
</div>
<div class='col-md-2'>
<h3 class='text-center text-white'>$jdate</h3>
</div>
</div>";
}
}
if (isset($_POST['tbkd'])) {
$bid=$_POST['bid'];
$pdate=$_POST['date'];
$sql2="SELECT * FROM bus_details WHERE bus_id='$bid'";
$run2=mysqli_query($con,$sql2);
$row1=mysqli_fetch_array($run2);
$fare=$row1['fare'];
$sql="SELECT * FROM ticket WHERE bus_id='$bid'AND jdate='$pdate'";
$run=mysqli_query($con,$sql);
if (mysqli_num_rows($run)==0) {
echo "<h4 class='text-center text-white'>Result Not Found</h4>";
}else{
while ($row=mysqli_fetch_array($run)) {
$pname=$row['pname'];
$jdate=$row['jdate'];
$seat_no=$row['seat_no'];
$no_seat=$row['no_seat'];
$status=$row['ticket_status'];
$tfare=$fare*$no_seat;
echo " <div class='row'>
<div class='col-md-2'>
<h3 class='text-center text-white'> $pname</h3>
</div>
<div class='col-md-2'>
<h3 class='text-center text-white'>$seat_no</h3>
</div>
<div class='col-md-2'>
<h3 class='text-center text-white'>$no_seat</h3>
</div>
<div class='col-md-2'>
<h3 class='text-center text-white'>$tfare</h3>
</div>
<div class='col-md-2'>
<h3 class='text-center text-white'>$status</h3>
</div>
<div class='col-md-2'>
<h3 class='text-center text-white'>$jdate</h3>
</div>
</div>";
}
}
}
?>