-
Notifications
You must be signed in to change notification settings - Fork 20
/
join.php
402 lines (382 loc) · 18.3 KB
/
join.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
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
<?php
session_start();
if($_SESSION['status']=='loggedin')
{
?>
<!DOCTYPE html>
<html>
<head>
<title>Letstravel</title>
<link rel="shortcut icon" href="images/favicon.png">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1">
<!--Bootstrap CSS-->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,500" rel="stylesheet">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="override.css">
<link rel="stylesheet" type="text/css" href="join.css">
</head>
<body class="bg">
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
<a class="navbar-brand heading" href="home.php">Letstravel</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div id="navbarNavDropdown" class="navbar-collapse collapse">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="home.php?status=loggedin">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="home.php?status=loggedin#Upcoming">Upcoming Trips</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://www.google.com">FAQ</a>
</li>
</ul>
<ul class="navbar-nav">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="http://example.com" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Hi,
<?php
$servername = 'localhost';
$username = 'root';
$password = '';
$db='letstravel';
$conn = mysqli_connect($servername,$username,$password,$db);
if (!$conn)
{
die("Connection failed: " . mysqli_connect_error());
}
$email=$_SESSION['user_email'];
$sql="SELECT FirstName FROM user WHERE Email='".$email."'";
$fname = mysqli_query($conn,$sql);
while ($row=$fname->fetch_assoc()) {
echo $row['FirstName'];
}
$_SESSION['tripid']=$_POST['tripid'];
//echo $_SESSION['tripid'];
?>
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<!-- <a class="dropdown-item" href="#">Edit Profile</a> -->
<a class="dropdown-item" href="logout.php">Logout</a>
</div>
</li>
</ul>
</div>
</nav>
<!--main form-->
<form action="upload.php" method="POST">
<div class="joinForm">
<div class="topButtons">
<label class="form-check-label" for="Pcount">Number of Passengers</label>
<input type="number" name="passengerCount" min="1" id="Pcount" value="1">
<a id="iniPCount" onclick="tablerows()" class="yellowBtn">Go!</a>
<a id="addbtn" onclick="addRow()" class="linkBtn">+ Add</a>
</div>
<table class="table" id="passengertable">
<thead class="thead-dark">
<tr>
<th scope="col">First Name</th>
<th scope="col">Last Name</th>
<th scope="col">Age</th>
<th scope="col">Gender</th>
<th scope="col">Contact</th>
<th scope="col">Aadhar Number</th>
<th scope="col"><input type="reset" value="Clear" class="linkBtn"></th>
</tr>
</thead>
<tbody>
<td><?php
$sql="SELECT FirstName FROM user WHERE Email='".$email."'";
$fname = mysqli_query($conn,$sql);
while ($row=$fname->fetch_assoc()) {
echo "<input type='text' name='fname0' value='".$row['FirstName']."'>";
}
?></td>
<td><?php
$sql="SELECT LastName FROM user WHERE Email='".$email."'";
$lname = mysqli_query($conn,$sql);
while ($row=$lname->fetch_assoc()) {
echo "<input type='text' name='lname0' value='".$row['LastName']."'>";
}
?></td>
<td><input name="age0" type='number' min='1'></td>
<td><select name='gender0'><option>Select</option><option>Male</option><option>Female</option></select></td>
<td><?php
$sql="SELECT Mobile FROM user WHERE Email='".$email."'";
$mobile = mysqli_query($conn,$sql);
while ($row=$mobile->fetch_assoc())
{
echo "<input type='text' name='contact0' maxlength='10' pattern='([0-9]{10})' value='".$row['Mobile']."'>";
}
if(isset($_POST['tripjoined']))
{
$tripid = $_POST["tripid"];
$sql = "SELECT locations FROM trip_location WHERE startloc=1 AND tripId='".$tripid."'";
$result = mysqli_query($conn,$sql);
$num=mysqli_num_rows($result);
for($i=0;$i<$num;$i++)
{
$row=mysqli_fetch_assoc($result);
$startloc = $row["locations"];
}
$sql = "SELECT BasePrice FROM trip WHERE tripId='".$tripid."'";
$result = mysqli_query($conn,$sql);
for($i=0;$i<mysqli_num_rows($result);$i++)
{
$row=mysqli_fetch_assoc($result);
$baseprice = $row["BasePrice"];
}
}
?></td>
<td><input type='text' pattern='([0-9]{16})' maxlength='16' name='aadharno0'></td>
<td><button onclick='delRow(this)' class="delBtn"><i class='fa fa-trash' aria-hidden='true'></i></button></td>
</tbody>
</table>
<div class="form-group row">
<label for="Locations" class="col-xl-3 col-form-label">From</label>
<div class="col-xl-9">
<select name='from_loc' class="form-control selectloc" id="Locations" onchange="javascript:getdata();">
<option selected="" disabled="">Select Location</option>
<!--<option>Mumbai</option>
<option>Delhi</option>
<option>Bangalore</option>
<option>Kolkata</option>-->
<?php
$sql5="SELECT City FROM distance";
$city = mysqli_query($conn,$sql5);
while ($row5=$city->fetch_assoc())
{
echo "<option value='".$row5['City']."'>".$row5['City']."</option>";
}
?>
</select>
</div>
</div>
<div class="form-group row ">
<label for="accpref" class="col-xl-3 col-form-label">Accomodation preference</label>
<div id="accpref" class="col-xl-9">
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="accpref" id="3star" value="3star" onchange="javascript:getcost();">
<label class="form-check-label" for="3star">3-star</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="accpref" id="5star" value="5star" onchange="javascript:getcost();">
<label class="form-check-label" for="5star">5-star</label>
</div>
</div>
</div>
<div class="form-group row ">
<label for="mealpref" class="col-xl-3 col-form-label">Meal preference </label>
<div id="mealpref" class="col-xl-9">
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="mealpref" id="veg" value="veg" onchange="javascript:getcost();">
<label class="form-check-label" for="veg">Veg</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="mealpref" id="nonveg" value="nonveg" onchange="javascript:getcost();">
<label class="form-check-label" for="nonveg">Non-Veg</label>
</div>
</div>
</div>
<div class="form-group row ">
<label for="travelpref" class="col-xl-3 col-form-label">Travel time preference</label>
<div id="travelpref" class="col-xl-9">
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="travelpref" id="day" value="day">
<label class="form-check-label" for="day">Day</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="travelpref" id="night" value="night">
<label class="form-check-label" for="night">Night</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="travelpref" id="any" value="any">
<label class="form-check-label" for="any">Any</label>
</div>
</div>
</div>
<div class="form-group row price">
<div class="totalCost" style="padding: 0%; margin: 0;">
<!--+500 for non veg, +5000 for 5 star -->
<p id="total"></p>
</div>
<div class="tnc" style="display: block;">
<p id="tncText" style="padding: 0%; margin: 0; margin-bottom: 1%;">*The above price is inclusive of travelling, accomodation, taxes and trip cost.</p>
</div>
</div>
<div class="form-group row">
<div class="col-xl-10" id="tncCheck">
<input class="" type="checkbox" name="tncCheck" value="agreed">
<label>I have read the terms and conditions and accept them</label>
</div>
</div>
<div class="form-group row col-md-12" class="foot">
<div class="form-check form-check-inline col-md-5">
<a href="home.php?status=loggedin"><button onclick="" class="secondaryBtn">Cancel</button></a>
</div>
<div class="form-check form-check-inline col-md-5 confirmBtn">
<input type="hidden" name="cost" id="costforpayment">
<input type="hidden" name="tripKaID" id="tripIdForMail" value="<?php echo $tripid;?>">
<input type="hidden" name="email" id="UseremailForMail" value="<?php echo $email;?>">
<input class="form-check-input yellowBtn bottomBtn" type="submit" name="JoinTrip" value="Proceed">
</div>
</div>
</form>
</div>
<!--Bootstrap JS-->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<script>
var passengers = parseInt(document.getElementById("Pcount").value,10);
var cost2=0;
var cost1=0;
var cost3=parseInt(<?php echo $baseprice; ?>,10);
document.getElementById("total").innerHTML = "Total cost ₹" + (cost1+cost2+cost3)*passengers+"*";
document.getElementById("costforpayment").value = (cost1+cost2+cost3)*passengers;
document.getElementById("price").style.display = "block";
window.onload=function(){
document.getElementById('addbtn').style.display = "none";
document.getElementById('tncText').style.display = "none";
}
function tablerows(){
var count = document.getElementById('Pcount').value;
var j = parseInt(count);
for(var i=1;i<j;i++)
{
var row = document.getElementById('passengertable').insertRow();
var firstname = row.insertCell(0);
var lastname = row.insertCell(1);
var age = row.insertCell(2);
var gender = row.insertCell(3);
var contact = row.insertCell(4);
var aadhar = row.insertCell(5);
var deleteRow = row.insertCell(6);
firstname.innerHTML="<input type='text' name='fname"+i+"'>";
lastname.innerHTML="<input type='text' name='lname"+i+"'>";
age.innerHTML = "<input type='number' name='age"+i+"' min='1'>";
gender.innerHTML = "<select name='gender"+i+"'><option>Select</option><option>Male</option><option>Female</option></select>";
contact.innerHTML = "<input type='text' name='contact"+i+"' maxlength='10' pattern='([0-9]{10})'>";
aadhar.innerHTML = "<input type='text' maxlength='16' name='aadharno"+i+"' pattern='([0-9]{16})'>";
deleteRow.innerHTML = "<button onclick='delRow(this)' class='delBtn'><i class='fa fa-trash' aria-hidden='true'></i></button>";
}
document.getElementById("iniPCount").style.display = "none";
document.getElementById("Pcount").readOnly = "true";
document.getElementById("addbtn").style.display="inline";
passengers = parseInt(document.getElementById("Pcount").value,10);
document.getElementById("total").innerHTML = "Total cost ₹" + (cost1+cost2+cost3)*passengers+"*";
document.getElementById("Pcount").value = passengers;
document.getElementById("costforpayment").value = (cost1+cost2+cost3)*passengers;
}
function addRow(){
var row1 = document.getElementById('passengertable').insertRow();
var firstname1 = row1.insertCell(0);
var lastname1 = row1.insertCell(1);
var age1 = row1.insertCell(2);
var gender1 = row1.insertCell(3);
var contact1 = row1.insertCell(4);
var aadhar1 = row1.insertCell(5);
var deleteRow1 = row1.insertCell(6);
firstname1.innerHTML="<input type='text' name='fname"+(passengers)+"'>";
lastname1.innerHTML="<input type='text' name='lname"+(passengers)+"'>";
age1.innerHTML = "<input type='number' name='age"+(passengers)+"' min='1'>";
gender1.innerHTML = "<select name='gender"+(passengers)+"'><option>Select</option><option>Male</option><option>Female</option></select>";
contact1.innerHTML = "<input type='text' name='contact"+(passengers)+"' maxlength='10' pattern='([0-9]{10})'>";
aadhar1.innerHTML = "<input type='text' maxlength='16' name='aadharno"+(passengers)+"' pattern='([0-9]{16})'>";
deleteRow1.innerHTML = "<button onclick='delRow(this)' class='delBtn'><i class='fa fa-trash' aria-hidden='true'></i></button>";
var cnt = document.getElementById("Pcount").value;
var newcnt = parseInt(cnt)+1;
passengers = newcnt;
document.getElementById("Pcount").value = passengers;
document.getElementById("total").innerHTML = "Total cost ₹" + (cost1+cost2+cost3)*passengers+"*";
document.getElementById("costforpayment").value = (cost1+cost2+cost3)*passengers;
}
function delRow(r) {
var i = r.parentNode.parentNode.rowIndex;
document.getElementById("passengertable").deleteRow(i);
var cnt = document.getElementById("Pcount").value;
var newcnt = parseInt(cnt)-1;
passengers = newcnt;
document.getElementById("total").innerHTML = "Total cost ₹" + (cost1+cost2+cost3)*passengers+"*";
document.getElementById("Pcount").value = passengers;
document.getElementById("costforpayment").value = (cost1+cost2+cost3)*passengers;
}
function getdata()
{
var selected_locn = document.getElementById("Locations").value;
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function(){
if(xhttp.readyState == 4 && xhttp.status == 200)
{
var jsobj = JSON.parse(xhttp.response);
for(var i=0;i<jsobj.length;i++)
{
if(selected_locn==jsobj[i].City)
{
cost1 = parseInt(jsobj[i].<?php echo $startloc; ?>,10);
cost1 = cost1*2;
console.log(cost1);
document.getElementById("total").innerHTML = "Total cost ₹" + (cost1+cost2+cost3)*passengers+"*";
}
}
}
};
xhttp.open("GET","distance.json",true);
xhttp.send();
document.getElementById("costforpayment").value = (cost1+cost2+cost3)*passengers;
}
function getcost()
{
var acc_pref = "3star";
var meal_pref = "veg";
if(document.getElementById("3star").checked)
{
acc_pref = document.getElementById("3star").value;
}
if(document.getElementById("5star").checked)
{
acc_pref = document.getElementById("5star").value;
}
if(document.getElementById("veg").checked)
{
meal_pref = document.getElementById("veg").value;
}
if(document.getElementById("nonveg").checked)
{
meal_pref = document.getElementById("nonveg").value;
}
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function(){
if(xhttp.readyState == 4 && xhttp.status == 200)
{
var jsobj = JSON.parse(xhttp.response);
for(var i=0;i<jsobj.length;i++)
{
if((meal_pref==jsobj[i].meal_pref) && (acc_pref==jsobj[i].acc_pref))
{
cost2 = parseInt(jsobj[i].cost,10);
console.log(cost2);
document.getElementById("total").innerHTML = "Total cost ₹" + (cost1+cost2+cost3)*passengers+"*";
}
}
}
};
xhttp.open("GET","cost.json",true);
xhttp.send();
document.getElementById("costforpayment").value = (cost1+cost2+cost3)*passengers;
}
</script>
</body>
</html>
<?php
}
else
{
header("location:userlogin.html");
}
mysqli_close($conn);
?>