-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdetails.php
More file actions
145 lines (125 loc) · 4.73 KB
/
details.php
File metadata and controls
145 lines (125 loc) · 4.73 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
<body style="background:#34495e">
<style type="text/css">
legend {
width: 170px;
padding: 2px;
margin-left: calc(50% - 100px - 8px);
font-weight:bold;
font-family:sans-serif;
color:white;
}
.title {
font-size: 24px;
color: white;
font-weight: 400;
margin-bottom: 40px;
}
.input-group {
position: relative;
margin-bottom: 22px;
}
.label {
font-size: 16px;
font-weight:bold;
font-family:sans-serif;
color: white;
text-transform: capitalize;
display: block;
margin-bottom: 5px;
}
.input-style {
line-height: 30px;
background: #fafafa;
border-radius: 5px;
padding: 0 20px;
font-size: 16px;
color: #666;
}
</style>
<?php
define('DBSERVER', 'localhost');
define('DBUSERNAME', 'root');
define('DBPASSWORD', '');
define('DBNAME', 'bus');
$db=mysqli_connect(DBSERVER,DBUSERNAME,DBPASSWORD,DBNAME);
if($db===false){
die("Error: connection error.".mysql_connect_error());
}
$drp8="DROP TABLE bookfinal";
mysqli_query($db,$drp8);
$bus_no=$_GET['bus_no'];
$source=$_GET['source'];
$destination=$_GET['destination'];
$seats=$_GET['test'];
$date=$_GET['date'];
$arr=explode(",",$seats);
$i=1;
echo '<h2 class="title" style="text-align:center;">Passenger Information</h2>';
echo '<form name="myform" >';
foreach ($arr as &$value) {
echo "<div style='margin-left:250px; margin-top:20px; width:800px'>";
printf("<fieldset ><legend> Passenger %u | Seat %u </legend>",$i,$value);
$a="gender";
$a.=$i;
echo '<div style="margin-left:100px" >';
echo '<br>';
echo '<div class="input-group">
<label class="label">Name</label>
<input class="input-style" type="text" name="name[]" id="c_name" size="50" required="required">
</div>';
echo '<div class="input-group">
<label class="label"> Email ID</label>
<input class="input-style" size="50" name="emailid[]" type="text" >
</div>';
echo '<div class="input-group">
<label class="label" >Gender</label>
<input type="radio" id="male" name="'.$a.'" value="male">
<label style="color:white" for="male">Male</label>
<input type="radio" id="female" name="'.$a.'" value="female">
<label style="color:white" for="female">Female</label>
</div>';
echo '<div class="input-group">
<label class="label"> Age</label>
<input class="input-style" name="age[]" type="number" pattern="/^[1-9]?[0-9]{1}$|^150$/" data-validation-msg="Please enter valid Age" >
</div>';
echo'</div>';
$i=$i+1;
echo '</fieldset>';
echo "</div>";
}
echo '</form>';
echo '<button style="margin-left:600px;padding:10px 20px;font-weight:bold;font-family:sans-serif" id="submit" name="submit" value="submit">Submit</button>';
?>
</body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
function submitForm() {
var name=document.getElementsByName('name[]');
count=name.length;
var gender = [];
for (var i=1;i<count+1;i++){
var g='gender'+i;
var k=$(document.getElementsByName(g)).serialize()
var t=k.replace('gender'+i+'=', "");
gender[i-1]=t;
}
var age=document.getElementsByName('age[]');
var emailid=document.getElementsByName('emailid[]');
var NAME=[] ,GENDER=[],AGE=[],EMAILID=[];
count=name.length;
for (var i=0;i<count;i++){
NAME[i]=name[i].value;
GENDER[i]=gender[i];
AGE[i]=age[i].value;
EMAILID[i]=emailid[i].value;
}
console.log(NAME);
console.log(GENDER);
console.log(AGE);
console.log(EMAILID);
document.location="final1.php?names="+NAME+"&bus_no="+"<?php echo $bus_no ?>"+"&source="+"<?php echo $source ?>"+"&destination="+"<?php echo $destination ?>"+"&genders="+GENDER+"&ages="+AGE+"&emailids="+EMAILID+"&date="+"<?php echo $date ?>"+"&seats="+"<?php echo $seats ?>";
}
$("#submit").click(submitForm);
});
</script>