-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
312 lines (259 loc) · 13.4 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
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
<?php
session_start();
require 'includes/connection.php';
$userID_error = $pass_error = "";
// login form
if(isset($_POST['submit'])) {
$userID = mysqli_real_escape_string($link, $_POST['userID']);
$password = mysqli_real_escape_string($link, $_POST['password']);
//Error Handlers
//Check if inputs are empty
if (empty($userID) || empty($password)) {
echo "empty";
} else {
$sql = "SELECT * FROM users WHERE userID = '$userID'";
$result = mysqli_query($link, $sql);
$resultCheck = mysqli_num_rows($result);
if ($resultCheck == 0) {
echo '<div class="alert alert-danger alert-dismissable" id="flash-msg">
<button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
<h4><i class="icon fa fa-times"></i>The service number you have entered does not exist!</h4>
</div>';
} else {
if($row = mysqli_fetch_assoc($result)) {
//De-hashing the password!
if(password_verify($password, $row['password'])){
$_SESSION['userID'] = $row['userID'];
$_SESSION['fname'] = $row['fname'];
$_SESSION['lname'] = $row['lname'];
$_SESSION['domain'] = $row['domain'];
$_SESSION['regionID'] = $row['regionID'];
$_SESSION['stationID'] = $row['stationID'];
if( $_SESSION['domain'] == 1) {
header("Location: pages/adminhome.php?loggedIn=".$_SESSION['userID']);
}elseif ($_SESSION['domain'] == 0)
{
header("Location: pages/homepage.php?success=1");
}
} else {
echo '<div class="alert alert-danger alert-dismissable" id="flash-msg">
<button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
<h4><i class="icon fa fa-times"></i>wrong password!</h4>
</div>';
echo mysqli_error($link);
}
}
}
}
}
// report form
if(isset($_POST['notSubmit'])){
$lat=$_SESSION['lat'];
$lng=$_SESSION['lng'];
$numplate = mysqli_real_escape_string($link,$_POST['numplate']);
$region = mysqli_real_escape_string($link,$_POST['region']);
$phoneno = mysqli_real_escape_string($link,$_POST['phoneno']);
$description = mysqli_real_escape_string($link,$_POST['description']);
$station = mysqli_real_escape_string($link,$_POST['station']);
$sql = "INSERT INTO `notifications`( `numPlate`, `description`, `regionID`,`stationID`, `phone`, `lat`, `lng`) VALUES ('$numplate', '$description','$region','$station','$phoneno', '$lat', '$lng')";
mysqli_query($link, $sql);
echo "<script>";
echo"Swal.fire({
title: 'Thankyou for reporting the incident. Our team has been dispatched',
showClass: {
popup: 'animated fadeInDown faster'
},
hideClass: {
popup: 'animated fadeOutUp faster'
}
})";
echo"</script>";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>TORS</title>
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Fira+Sans|Roboto:300,400|Questrial|Satisfy">
<link rel="stylesheet" type="text/css" href="css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/animate.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
<link rel="shortcut icon" href="pages/images/favicon.ico" type="image/png">
<link href="https://fonts.googleapis.com/css?family=Roboto|Varela+Round" rel="stylesheet">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<script type="text/javascript" src="js/jquery/jquery.min.js"></script>
<link rel="stylesheet" href="js/sweetalert.min.js">
</head>
<!-- picking stations for a specific region -->
<?php include "includes/connection.php"; ?>
<script>
function getStations(val) {
$.ajax({
type: "POST",
url: "includes/getstations.php",
data: 'regionID=' + val,
success: function(data) {
$("#stations").html(data);
}
});
}
</script>
<body id="myPage" data-spy="scroll" data-target=".navbar" data-offset="60">
<div class="header">
<div class="bg-color">
<header id="main-header">
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#lauraMenu">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">TORS</a>
</div>
<div class="collapse navbar-collapse" id="lauraMenu">
<ul class="nav navbar-nav navbar-right navbar-border">
<li class="active"><a href="#main-header">Home</a></li>
<li><a href="#contact">Report an Incident</a></li>
<li><a href="pages/addnewdriver.php">Driver Registration</a></li>
<li><a href="" data-toggle="modal" data-target="#myModal">Login</a></li>
</ul>
<!-- Sign In Modal-->
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog modal-login">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Officer Log In</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<form method="post" action="index.php">
<div class="form-group">
<!-- <div class="form-control">
<?php echo $userID_error; ?>
</div> -->
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-user"></i></span>
<input type="text" class="form-control" name="userID" placeholder="Service Number" required="required">
</div>
</div>
<div class="form-group">
<!-- <div class="form-control">
<?php echo $pass_error; ?>
</div> -->
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-lock"></i></span>
<input type="password" class="form-control" name="password" placeholder="Password" required="required">
</div>
</div>
<div class="form-group">
<input type="submit" class="btn btn-primary btn-block btn-md" name="submit" value="Log In">
</div>
<p class="hint-text"><a href="reset-password.php">Forgot Password?</a>
</p>
</form>
<!-- here we create the form which starts the password recovery -->
</div>
<div class="modal-footer">Don't have an account? <a href="#">Contact Admin</a>
</div>
</div>
</div>
</div>
<!-- End Sign In Modal-->
</div>
</div>
</nav>
</header>
<div class="wrapper">
<div class="container">
<div class="row">
<div class="col-md-12 wow fadeIn delay-05s">
<div class="banner-text">
<p>Traffic Offenders Registration <br>System </p>
<h2> <span>Making our roads safer</span></h2>
</div>
<div class="overlay-detail text-center">
<a href="#contact"><i class="fa fa-angle-down"></i></a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<section id="contact" class="section-padding wow fadeIn delay-05s">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="contact-sec text-center">
<h2>Witnessed an incident/accident on the road?</h2>
<p>Report to us</p>
</div>
</div>
<div class="col-md-8 col-md-push-2">
<div id="sendmessage">
</div>
<!-- <div id="errormessage"></div>-->
<?php require 'geolocation.php'; ?>
<form action="index.php" method="post" role="form" class="contactForm">
<div class="form-group">
<input type="type" class="form-control" name="numplate" id="numplate" placeholder="Number plate" data-msg="Please enter a number plate" />
<div class="validation"></div>
</div>
<!-- selecting station -->
<div class="form-group">
<select name="region" class="form-control" onchange="getStations(this.value);">
<option disabled selected value="">Select Region</option>
<?php
require_once 'includes/connection.php';
$sql = "SELECT * FROM regions";
$result = $link->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo '<option value="'.$row["regionID"].'" >'.$row["regionName"].'</option>';
}
} else {
}
?>
</select>
</div>
<!-- selecting station end -->
<div class="form-group">
<select class="form-control" name="station" id="stations">
<option value="">Select Station</option>
</select>
<div class="validation"></div>
</div>
<div class="form-group">
<input type="number" class="form-control" name="phoneno" id="phoneno" placeholder="Phone No" data-msg="Please enter a phone number" />
<div class="validation"></div>
</div>
<div class="form-group">
<textarea class="form-control" name="description" id="description" rows="5" data-rule="required" data-msg="Please give a brief description of the incident" placeholder="Description of the incident"></textarea>
<div class="validation"></div>
</div>
<div align="center" class="text-center"><button style="display:none;" type="submit" id="notSubmit" name="notSubmit"
class="btn btn-primary btn-lg showButton">Report</button>
</div>
</form>
</div>
</div>
</div>
</section>
<script src="js/jquery.min.js"></script>
<script src="js/jquery.easing.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/wow.js"></script>
<script src="js/custom.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#flash-msg").delay(2000).fadeOut("slow");
});
</script>
</body>
</html>