-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA_Non_Vehicle_Registration.php
304 lines (252 loc) · 9.69 KB
/
A_Non_Vehicle_Registration.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
<?php require_once('connection.php');
session_start();
/**
* @author Yasiru
* contact me : https://linktr.ee/yasiruchamuditha for more information.
*/
if(isset($_POST["btnSubmit"]))
{
if (isset($_SESSION["Email"]))
{
$Email=$_POST["txtEmail"];
$Registration_No=$_POST["txtRegistrationNo"];
$Instrument_Type=$_POST["txtInstrumentType"];
$Fuel_Capacity=$_POST["txtFuelCapacity"];
$Fuel_Type=$_POST["FuelType"];
//perform sql
$sql = "INSERT INTO instrument_registration (Registration_No,Instrument_Type,Fuel_Capacity,Fuel_Type) VALUES ('$Registration_No','$Instrument_Type','$Fuel_Capacity','$Fuel_Type')";
$ret= mysqli_query($con, $sql);
echo '<script>alert("Successfuly Registered")</script>';
header('location:A_Admin.php');
}
else
{
header("location:M_User_Login.php");
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Non Vehicle Registration</title>
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<meta content="Fuel Up" name="keywords">
<meta content="Fuel Status" name="description">
<!-- Favicon -->
<link href="img/favicon.ico" rel="icon">
<!-- Google Web Fonts -->
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Oswald:wght@400;500;600;700&family=Rubik&display=swap" rel="stylesheet">
<!-- Font Awesome -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.0/css/all.min.css" rel="stylesheet">
<!-- Libraries Stylesheet -->
<link href="lib/owlcarousel/assets/owl.carousel.min.css" rel="stylesheet">
<link href="lib/tempusdominus/css/tempusdominus-bootstrap-4.min.css" rel="stylesheet" />
<!-- Customized Bootstrap Stylesheet -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<!-- css Stylesheet -->
<link href="css/style.css" rel="stylesheet">
<link href="css/styleRegistrations.css" rel="stylesheet">
<script src="https://kit.fontawesome.com/c4254e24a8.js" crossorigin="anonymous"></script>
</head>
<body style="background-image: url(img/registration.png);">
<?php require('A_Navigation_Bar.php');?>
<div class="container-fluid">
<div class="container mt-3">
<h1 >Non Vehicle Registration</h1>
<form class="row g-3 needs-validation" action="#" method="post" onsubmit="return result()">
<!--Instrument Registration No-->
<div class="inputfeild mt-3">
<label for="Instrument Registration No" class="form-label">Instrument Registration No</label>
<input type="text" class="form-control" id="txtRegNo" name="txtRegistrationNo" placeholder="Instrument Registration No" onkeyup="validateRegistrationNo()">
<div>
<label for="RegNoHelp" class="form-text">If you don't have registered with the government please enter the owner NIC number as Instrument Registration Number.</label>
<span id="Registration_Error"></span>
</div>
</div>
<!--Instrument Type-->
<div class="inputfeild mt-2">
<label for="Instrument Type" class="form-label">Instrument Type</label>
<input type="text" class="form-control" name="txtInstrumentType" id="txtInstrumentType" placeholder="Instrument Type" onkeyup="validateInstrumentType()" >
<span id="InstrumentType_Error"></span>
</div>
<!--Fuel Capacity-->
<div class="inputfeild mt-2">
<label for="Fuel_Capacity" class="form-label">Fuel Capacity</label>
<input type="text" class="form-control" id="txtFuelCapacity" name="txtFuelCapacity" placeholder="Fuel Capacity" onkeyup="validateFuelCapacity()">
<span id="FuelCapacity_Error"></span>
</div>
<!--Fuel Type-->
<div class="inputfeild mt-2 form-group">
<label for="FuelTypes" class="form-label">Fuel Type</label>
<select id="FuelType" name="FuelType" class="form-control" onkeyup="validateFUELTYPE()">
<option value="S">Choose...</option>
<option value="Petrol">Petrol</option>
<option value="Diesal">Diesal</option>
<option value="Kerosine Oil">Kerosine Oil</option>
<option value="Industrial Kerosine Oil">Industrial Kerosine Oil</option>
<option value="Fuel Oil">Fuel Oil </option>
</select>
<span id="FuelType_Error"></span>
</div>
<!--EMAIL No -->
<div class="inputfeild mt-2">
<label for="Email" class="form-label">UserEmail</label>
<input type="text" class="form-control" name="txtEmail" id="txtEmail" placeholder="[email protected]" onkeyup="validateEmail()" >
<span id="Email_Error"></span>
</div>
<!--Check Terms -->
<div class="inputfeild mt-3 mx-2 form-check">
<input type="checkbox" class="form-check-input" name="chkCheck" id="chStatus" onkeyup="validateTerms()" >
<label class="form-check-label" for="exampleCheck1">Agree to Terms and Conditions</label><br>
<span id="Check_Error"></span>
</div>
<!--Button-->
<button type="submit" id="btnSubmit" class="btn btn-outline-primary btn-lg" name="btnSubmit" >Submit</button>
</form>
</div>
</div>
<?php require('A_Footer.php');?>
<!-- JavaScript Libraries -->
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.bundle.min.js"></script>
<script src="lib/easing/easing.min.js"></script>
<script src="lib/waypoints/waypoints.min.js"></script>
<script src="lib/owlcarousel/owl.carousel.min.js"></script>
<script src="lib/tempusdominus/js/moment.min.js"></script>
<script src="lib/tempusdominus/js/moment-timezone.min.js"></script>
<script src="lib/tempusdominus/js/tempusdominus-bootstrap-4.min.js"></script>
<!-- Template Javascript -->
<script src="js/main.js"></script>
<script type="text/javascript">
var Registration_Error=document.getElementById('Registration_Error');
var InstrumentType_Error=document.getElementById('InstrumentType_Error');
var FuelCapacity_Error=document.getElementById('FuelCapacity_Error');
var FuelType_Error=document.getElementById('FuelType_Error');
var Email_Error=document.getElementById('Email_Error');
var Check_Error=document.getElementById('Check_Error');
function validateRegistrationNo()
{
var Registration_no=document.getElementById('txtRegNo').value.replace(/^\s+|\s+$/g, "");
if(Registration_no.length == 0)
{
Registration_Error.innerHTML='Registration number is required.';
return false;
}
else
{
var reOLD = /^[0-9]{9}[V]{1}$/;
var re = /^[0-9]{13}$/;
//var re = /^[a-zA-Z0-9_]+$/;
if((!Registration_no.match(re)) && ((!Registration_no.match(reOLD)) ))
{
Registration_Error.innerHTML='Please Enter Registration number in correct format and correct length.';
return false;
}
}
Registration_Error.innerHTML = '<i class="fa-regular fa-circle-check"></i>';
return true;
}
function validateInstrumentType()
{
var Instrument_Type=document.getElementById('txtInstrumentType').value.replace(/^\s+|\s+$/g, "");
if(Instrument_Type.length == 0)
{
InstrumentType_Error.innerHTML='Instrument Type is required.';
return false;
}
InstrumentType_Error.innerHTML = '<i class="fa-regular fa-circle-check"></i>';
return true;
}
function validateFuelCapacity()
{
var Fuel_Capacity=document.getElementById('txtFuelCapacity').value.replace(/^\s+|\s+$/g, "");
if(Fuel_Capacity.length == 0)
{
FuelCapacity_Error.innerHTML='Fuel Capacity is required.';
return false;
}
else
{
//var re = /^[0-9]{9}$/;
var re = /^[0-9]+$/;
if(!Fuel_Capacity.match(re))
{
FuelCapacity_Error.innerHTML='Please Enter NUMBER.';
return false;
}
}
FuelCapacity_Error.innerHTML = '<i class="fa-regular fa-circle-check"></i>';
return true;
}
function validateFUELTYPE()
{
if(document.getElementById("FuelType").value == "S")
{
FuelType_Error.innerHTML='Fuel Type is required.';
return false;
}
FuelType_Error.innerHTML = '<i class="fa-regular fa-circle-check"></i>';
return true;
}
document.getElementById("FuelType").addEventListener("click", function() {
if (document.getElementById("FuelType").value != "S") {
FuelType_Error.innerHTML = '<i class="fa-regular fa-circle-check"></i>';
return true;
}
});
function validateEmail()
{
var Email = document.getElementById('txtEmail').value.replace(/^\s+|\s+$/g, "");
if (Email.length == 0)
{
Email_Error.innerHTML='Email is required.';
return false;
}
else
{
var emaiPattern = /^[^ ]+@[^ ]+\.[a-z]{2,3}$/;
if (!Email.match(emaiPattern))
{
Email_Error.innerHTML='Please Enter Email in correct format.';
return false;
}
Email_Error.innerHTML = '<i class="fa-regular fa-circle-check"></i>';
return true;
}
}
function validateTerms()
{
if(document.getElementById("chStatus").checked == false)
{
Check_Error.innerHTML='Please Agree To Terms and Conditions.';
return false;
}
Check_Error.innerHTML = '<i class="fa-regular fa-circle-check"></i>';
return true;
}
document.getElementById("chStatus").addEventListener("click", function() {
if(document.getElementById('chStatus').checked == true){
Check_Error.innerHTML = '<i class="fa-regular fa-circle-check"></i>';
return true;
}
});
function result()
{
validateRegistrationNo();
validateInstrumentType();
validateFUELTYPE();
validateFuelCapacity();
validateEmail();
validateTerms();
if((!validateRegistrationNo()) || (!validateInstrumentType()) ||(!validateFUELTYPE()) ||(!validateFuelCapacity()) || (!validateEmail()) || (!validateTerms()) )
{
return false;
}
}
</script>
</body>
</html>