-
Notifications
You must be signed in to change notification settings - Fork 0
/
insert_into_train_3.php
140 lines (102 loc) · 3.75 KB
/
insert_into_train_3.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
<html>
<head>
<title>RAILWAY RESERVATION SYSTEM</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<link rel="stylesheet" href="index.css">
</head>
<body class=home>
<div id="container">
<nav class="navbar navbar-expand-lg navbar-dark bg-black">
<a class="navbar-brand" id="n">Railway Management System</a>
</nav>
</div>
<?php
session_start();
require "db.php";
if(isset($_POST["ns"]))
{
$ns=$_POST["ns"];
$tname=$_POST["tname"];
$_SESSION["tname"] = "$tname";
$sp=$_POST["sp"];
$_SESSION["sp"] = "$sp";
$st=$_POST["st"];
$_SESSION["st"] = "$st";
$dp=$_POST["dp"];
$_SESSION["dp"] = "$dp";
$dt=$_POST["dt"];
$_SESSION["dt"] = "$dt";
$dd=$_POST["dd"];
$_SESSION["dd"] = "$dd";
$ns=$_POST["ns"];
$_SESSION["ns"] = "$ns";
$ds=$_POST["ds"];
$_SESSION["ds"] = "$ds";
echo "<table><thead><td>Train_name</td><td>Starting_point</td><td>Starting_time</td><td>Destination_point</td><td>Destination_time</td><td>Day_of_arrival</td><td>No_of_stations</td><td>Distance</td></thead>";
echo "<tr><td>".$tname."</td><td>".$sp."</td><td>".$st."</td><td>".$dp."</td><td>".$dt."</td><td>".$dd."</td><td>".$ns."</td><td>".$ds."</td></tr></table>";
echo " <table><thead><td>Station</td><td>Arrival_Time</td><td>Departure_Time</td><td>Distance</td></thead>";
echo " <tr><td>".$sp."</td><td>".$st."</td><td>".$st."</td><td>0</td></tr>";
echo "<form action=\"insert_into_train_4.php\" method=\"post\">";
$temp=1;
while ($temp<=$ns)
{
echo " <tr><td><select id=\"stn".$temp."\" name=\"stn".$temp."\"required> ";
$cdquery="SELECT sname FROM station";
$cdresult=mysqli_query($conn,$cdquery);
echo " <option value = \"\" > </option>";
while ($cdrow=mysqli_fetch_array($cdresult))
{
$cdTitle=$cdrow['sname'];
echo " <option value = \"$cdTitle\" > $cdTitle </option>";
}
echo "
</select></td>
<td><input type=\"text\" name=\"st".$temp."\" required></td>
<td><input type=\"text\" name=\"dt".$temp."\" required></td>
<td><input type=\"text\" name=\"ds".$temp."\" required></td>
</tr>";
$temp+=1;
}
echo " <tr><td>".$dp."</td><td>".$dt."</td><td>".$dt."</td><td>".$ds."</td></tr></table>";
echo "<input type=\"submit\">";
}
else if($ns==0)
{
echo "
<form action=\"insert_into_train_3.php\" method=\"post\">
<table>
<tr><td>Train Name </td><td> <input type=\"text\" name=\"tname\" required></td></tr>
<tr><td>Starting Point </td><td> <select id=\"sp\" name=\"sp\" required>
";
$cdquery="SELECT sname FROM station";
$cdresult=mysqli_query($conn,$cdquery);
while ($cdrow=mysqli_fetch_array($cdresult))
{
$cdTitle=$cdrow['sname'];
echo " <option value = \"$cdTitle\" > $cdTitle </option>";
}
echo "
</select></td></tr>
<tr><td>Starting Time </td><td> <input type=\"time\" name=\"st\" required></td></tr>
<tr><td>Destination Point </td><td> <select id=\"dp\" name=\"dp\" required>
";
$cdquery="SELECT sname FROM station";
$cdresult=mysqli_query($conn,$cdquery);
while ($cdrow=mysqli_fetch_array($cdresult))
{
$cdTitle=$cdrow['sname'];
echo " <option value = \"$cdTitle\" > $cdTitle </option>";
}
echo "
</select></td></tr>
<tr><td>Destination Time </td><td> <input type=\"time\" name=\"dt\" required></td></tr>
<tr><td>Distance </td><td> <input type=\"text\" name=\"ds\" required></td></tr>
<tr><td>No Of Intermediate stations</td><td><input type=\"text\" name=\"ns\" required></td></tr>
<tr><td>Day of Arrival </td><td> <input type=\"text\" name=\"dd\" required></td></tr>
</table>
<input type=\"submit\" value=\"Enter Train Details\">
";}
echo "<br> <a href=\"http://localhost/railway/admin_login.php\">Go Back to Admin Menu!!!</a> ";
?>
</body>
</html>