forked from ajwad-shaikh/BusKaro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
207 lines (173 loc) · 5.83 KB
/
index.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
<?php
require('dbconn.php');
?>
<!DOCTYPE html>
<html>
<!-- Head -->
<head>
<title>BusKaro</title>
<!-- Meta-Tags -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="keywords" content="BusKaro, 24x7 Institute Bus Booking Portal" />
<script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
<!-- //Meta-Tags -->
<!-- Style --> <link rel="stylesheet" href="css/style.css" type="text/css" media="all">
<!-- Fonts -->
<link href="//fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet">
<!-- //Fonts -->
<!-- JQuery -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
</head>
<!-- //Head -->
<!-- Body -->
<body>
<h1>BusKaro</h1>
<h3>Book Bus Tickets On The Go</h3>
<br>
<div class="container">
<div class="login">
<h2>Sign In</h2>
<form action="index.php" method="post">
<p> Sign In As </p>
<select name="Type" id="type">
<option value="Student">Student</option>
<option value="Faculty">Faculty</option>
<option value="Staff">Staff</option>
<!--<option value="Guest">Guest</option>-->
</select>
<br>
<br>
<input type="number" Name="UserID" placeholder="User ID" required="">
<input type="password" Name="Password" placeholder="Password" required="">
<div class="send-button">
<!--<form>-->
<input type="submit" name="signin" value="Sign In">
</form>
</div>
<div class="clear"></div>
</div>
<div class="register">
<h2>Sign Up</h2>
<form action="index.php" method="post">
<p> Sign Up As </p>
<select name="Type" id="Type">
<option value="Student">Student</option>
<option value="Faculty">Faculty</option>
<option value="Staff">Staff</option>
<!--<option value="Guest">Guest</option>-->
</select>
<br> <br>
<script type="text/javascript">
$(document).ready(function(){
$('#Type').on('change', function(){
if(this.value == 'Faculty'){
$("#batch").hide();
$("#dept").show();
}
else if(this.value == 'Staff'){
$("#batch").hide();
$("#dept").hide();
}
else if(this.value == 'Student'){
$("#batch").show();
$("#dept").show();
}
});
});
</script>
<input type="number" Name="UserID" placeholder="User ID" required="">
<input type="text" Name="Name" placeholder="Name" required>
<input type="password" Name="Password" placeholder="Password" required>
<div id='batch'>
<input type="number" Name="Batch" placeholder="Batch">
</div>
<div id = 'dept'>
<p> Department </p>
<select name="Dept" id="Dept">
<option value="CSE">CSE</option>
<option value="ECE">ECE</option>
<option value="ME">ME</option>
<option value="NS">NS</option>
</select>
</div>
<br>
<p> Blood Group </p>
<select name="BloodG" id="BloodG">
<option value="A+">A+</option>
<option value="A-">A-</option>
<option value="AB+">AB+</option>
<option value="AB-">AB-</option>
<option value="B+">B+</option>
<option value="B-">B-</option>
<option value="O+">O+</option>
<option value="O-">O-</option>
</select>
<br><br>
<div class="send-button">
<input type="submit" name="signup" value="Sign Up">
</div>
</form>
<p>By creating an account, you agree to our <a class="underline" href="tandc.php">Terms</a></p>
<div class="clear"></div>
</div>
<div class="clear"></div>
<div class="footer w3layouts agileits">
<p><span class="copyleft">©</span> 2018 BusKaro. </a></p>
<p><a class="underline" href="aboutus.php">About the Project</a></p>
</div>
<?php
if(isset($_POST['signin']))
{$u=$_POST['UserID'];
$p=md5($_POST['Password']);
$c=$_POST['Type'];
$sql="SELECT * FROM buskaro.passenger WHERE ID='$u' AND Type='$c'";
$result = $conn->query($sql);
$row = $result->fetch_assoc();
$x=$row['Pwd'];
$y=$row['Type'];
if(strcasecmp($x,$p)==0 && !empty($u) && !empty($p))
{//echo "Login Successful";
$_SESSION['UserID']=$u;
$_SESSION['CheckID']=md5($u);
header('location:passenger/dashboard.php');
}
else
{ echo "<script type='text/javascript'>alert('Failed to Login! Incorrect RollNo or Password')</script>";
}
}
if(isset($_POST['signup']))
{
$userID=$_POST['UserID'];
$password=md5($_POST['Password']);
$name=$_POST['Name'];
$batch=$_POST['Batch'];
$dept=$_POST['Dept'];
$bloodG=$_POST['BloodG'];
$type=$_POST['Type'];
$conn->query('SET autocommit = OFF;');
$sql0 = "START TRANSACTION;";
$sql1="INSERT INTO buskaro.passenger (ID,Type,Pwd) VALUES ('$userID','$type','$password');";
if($type=='Student')
{
$sql2="INSERT INTO buskaro.student (RollNo, SName, Batch, Branch, BloodG) VALUES ('$userID','$name', '$batch', '$dept', '$bloodG');";
}
else if($type=='Faculty')
$sql2="INSERT INTO buskaro.faculty (FID, FName, Dept, BloodG) VALUES ('$userID','$name', '$dept', '$bloodG');";
else if($type=='Staff')
$sql2="INSERT INTO buskaro.staff (EID, EName, BloodG) VALUES ('$userID','$name','$bloodG');";
//else if($type=='Guest')
// $sql2="INSERT INTO buskaro.guest (GID, GName, Batch, Branch, DoB, BloodG) VALUES ('$userID','$name', '$batch', '$dept', '$bloodG');";
if (($conn->query($sql0) === TRUE) && ($conn->query($sql1) === TRUE) && ($conn->query($sql2) === TRUE) ){
echo "<script type='text/javascript'>alert('Registration Successful')</script>";
$conn->query('COMMIT;');
} else {
$conn->query('ROLLBACK;');
echo "Error: " . $sql . "<br>" . $conn->error;
echo "<script type='text/javascript'>alert('User Exists ".$conn->error."')</script>";
}
}
?>
</body>
<!-- //Body -->
</html>