-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshow_ticket.php
92 lines (72 loc) · 2.83 KB
/
show_ticket.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
<?php
session_start();
$dbhost="localhost";
$dbuser="adbms";
$dbpass="adbms";
$dbname="airplane_reservation";
$conn= mysqli_connect($dbhost,$dbuser,$dbpass,$dbname);
$source=$_POST["source"];
$destination=$_POST["destination"];
$day=$_POST["day"];
$month=$_POST["month"];
$year=$_POST["year"];
if ($source==$destination) {
echo "ERROR!!! destination and source cannot be the same";
die();
}
$temp=mysqli_query($conn,"SELECT DISTINCT place FROM locations WHERE location_id = $source");
while($row = $temp->fetch_assoc()){
$source = $row['place'];
}
$temp=mysqli_query($conn,"SELECT DISTINCT place FROM locations WHERE location_id = $destination");
while($row = $temp->fetch_assoc()){
$destination= $row['place'];
}
$temp=mysqli_query($conn,"SELECT DISTINCT base_price FROM planes WHERE source = '$source' AND destination = '$destination' ");
while($row = $temp->fetch_assoc()){
$base_price= $row['base_price'];
}
$_SESSION['source']=$source;
$_SESSION['destination']=$destination;
$_SESSION['day']=$day;
$_SESSION['month']=$month;
$_SESSION['year']=$year;
$_SESSION['base']=$base_price;
$ticket_price = $base_price - (100*$day) - ( 200* $month )+200;
$_SESSION['ticket_price']=$ticket_price;
?>
<!DOCTYPE html>
<html>
<head>
<!--Import Google Icon Font-->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!--Import materialize.css-->
<link type="text/css" rel="stylesheet" href="css/materialize.min.css" media="screen,projection"/>
<!--Let browser know website is optimized for mobile-->
<meta name="viewport" content="width=device-width, initial-scale=1.0"/></head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<div class="row">
<div class="col s12 m6">
<div class="card ">
<div class="card-content ">
<span class="card-title">Your Ticket</span>
<p>
<?php echo "From:".$source."                                                        To:".$destination."</br> </br> </br> On: ".$day." ".$month." ".$year."</br></br></br>Price :".$ticket_price; ?>
</p>
</div>
</div>
</div>
</div>
Do you want to book?
<form class="" action="book_ticket.php" method="post">
<button class="btn waves-effect waves-light" type="submit" name="action">Submit
<i class="material-icons right">send</i>
</button>
</form>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="js/materialize.min.js"></script>
</body>
</html>