-
Notifications
You must be signed in to change notification settings - Fork 0
/
booktkt.php
117 lines (115 loc) · 3.48 KB
/
booktkt.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
<?php
session_start();
if(empty($_SESSION['user_info'])){
echo "<script type='text/javascript'>alert('Please login before proceeding further!');</script>";
}
$conn = mysqli_connect("localhost","root","","railway");
if(!$conn){
echo "<script type='text/javascript'>alert('Database failed');</script>";
die('Could not connect: '.mysqli_connect_error());
}
if (isset($_POST['submit']))
{
$trains=$_POST['trains'];
$sql = "SELECT t_no FROM trains WHERE t_name = '$trains'";
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_assoc($result);
$email=$_SESSION['user_info'];
$query="UPDATE passengers SET t_no='$row[t_no]' WHERE email='$email';";
if(mysqli_query($conn, $query))
{
// echo "<script type = 'text/javascript'>alert(`{$trains}`)></script>";
$message = $trains;
// $message = $sql;
// $message = "Ticket booked successfully";
}
else {
$message="Transaction failed";
}
echo "<script type='text/javascript'>alert('$message');</script>";
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Book a ticket</title>
<LINK REL="STYLESHEET" HREF="css/style.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Baloo+Bhai+2&display=swap" rel="stylesheet">
<style type="text/css">
#booktkt {
margin:auto;
margin-top: 50px;
width: 40%;
height: 60%;
padding: auto;
padding-top: 50px;
padding-left: 50px;
background-color: rgba(0,0,0,0.3);
border-radius: 25px;
}
html {
background: url(img/bg7.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
#journeytext {
color: white;
font-size: 28px;
font-family: 'Baloo Bhai 2', cursive;
}
#trains {
/* margin-left: 90px; */
text-align: center;
font-size: 15px;
border: 2px solid black;
border-right: 5px solid black;
border-bottom: 5px solid black;
border-radius: 10px;
}
.submit {
width: 50px;
}
.custom{
background-color: white;
color: red;
}
</style>
<script type="text/javascript">
function validate() {
var trains=document.getElementById("trains");
if(trains.selectedIndex==0)
{
alert("Please select your train");
trains.focus();
return false;
}
}
</script>
</head>
<body>
<?php
include ('header.php');
?>
<div id="booktkt">
<h1 align="center" id="journeytext">Choose your journey</h1><br/><br/>
<form method="post" name="journeyform" onsubmit="return validate()">
<select id="trains" name="trains" required>
<option class="custom" selected disabled>-------------------Select trains here----------------------</option>
<option class="custom" value="rajdhani" >Rajdhani Express - Mumbai Central to Delhi</option>
<option class="custom" value="duronto" >Duronto Express - Mumbai Central to Ernakulum</option>
<option class="custom" value="geetanjali">Geetanjali Express - CST to Kolkata</option>
<option class="custom" value="garibrath" >Garib Rath - Udaipur to Jammu Tawi</option>
<option class="custom" value="mysoreexp" >Mysore Express - Talguppa to Mysore Jn</option>
<option class="custom" value="godanexp" >Godan Express - Lokmanya Tilak to Gorakhpur</option>
<option class="custom" value="chennaiexp" >Chennai Express - Dadar to Chennai Central</option>
</select>
<br/><br/>
<input type="submit" name="submit" id="submit" class="button" />
</form>
</div>
</body>
</html>