-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathform.php
More file actions
485 lines (412 loc) · 16.3 KB
/
form.php
File metadata and controls
485 lines (412 loc) · 16.3 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
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
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
<?php
include 'includes/head.inc.php';
$settingsq = "SELECT * FROM `settings` WHERE `id`=1";
$runsettings = $conn->query($settingsq);
$settings = mysqli_fetch_assoc($runsettings);
?>
<?php include 'partials/top.inc.php';
$surname_error=$firstname_eror=$dob_error=$age_error=$gender_error=$state_error=$tribe_error=$religion_error=$class_error=$pschool_error=$father_error=$father_occ_error=$father_addr_error=$father_phone_error=$mother_error=$mother_occ_error=$mother_addr_error=$mother_phone_error=$passport_error="";
$surname=$firstname=$othername=$dob=$age=$state=$tribe=$religion=$class=$pschool=$father=$father_occ=$father_addr=$father_phone=$mother=$mother_occ=$mother_addr=$mother_phone=$health=$dbpath="";
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
if($_SERVER["REQUEST_METHOD"]=="POST"){
if(!isset($_FILES['passport'])){
$passport_error ="Passport not uploaded";
}else{
$file_name = $_FILES['passport']['name'];
$file_size =$_FILES['passport']['size'];
@$file_tmp =$_FILES['passport']['tmp_name'];
$file_type=$_FILES['passport']['type'];
$allowed = array('png','jpg','jpeg','gif');
@$file_ext=explode('.',$_FILES['passport']['name']) ;
$file_ext=end($file_ext);
@$file_ext=strtolower(end(explode('.',$_FILES['passport']['name'])));
$uploadName = md5(microtime()).'.'.$file_ext;
$uploadPath = BASEURL.'/uploads/passports/'.$uploadName;
$dbpath='/uploads/passports/'.$uploadName;
if (($file_size > 100000)){
$passport_error ="File must be less than 100KB";
}else{
move_uploaded_file($file_tmp,$uploadPath);
}
}
if(empty($_POST['surname'])){
$surname_error="Field is Required";
}else{
$surname =test_input($_POST['surname']);
if(!preg_match("/^[a-zA-Z ]*$/",$surname)){
$surname_error ="Not a valid name";
}
}
if(empty($_POST['firstname'])){
$firstname_error="Name is Required";
}else{
$firstname =test_input($_POST['firstname']);
if(!preg_match("/^[a-zA-Z ]*$/",$firstname)){
$firstname_error ="Not a valid name";
}
}
if(empty($_POST['othername'])){
$othername =$_POST['othername'];
}else{
$othername =$_POST['othername'];
}
if(empty($_POST['dob'])){
$dob_error="Date of Birth is Required";
}else{
$dob =$_POST['dob'];
}
if(empty($_POST['age'])){
$age_error="Age by September Required";
}else{
$age =test_input($_POST['age']);
if(!preg_match("/^[0-9]{2}\z/",$age)){
$age_error ="Invalid Age";
}
}
if(empty($_POST['gender'])){
$gender_error="Gender Required";
}else{
$gender =$_POST['gender'];
}
if(empty($_POST['state'])){
$state_error="State is Required";
}else{
$state =test_input($_POST['state']);
if(!preg_match("/^[a-zA-Z ]*$/",$state)){
$state_error ="Please check state field";
}
}
if(empty($_POST['tribe'])){
$tribe_error="tribe is Required";
}else{
$tribe =test_input($_POST['tribe']);
if(!preg_match("/^[a-zA-Z ]*$/",$tribe)){
$tribe_error ="Please check tribe field";
}
}
if(empty($_POST['religion'])){
$religion_error="Religion Required";
}else{
$religion =$_POST['religion'];
}
if(empty($_POST['class'])){
$class_error="Class is Required";
}else{
$class =test_input($_POST['class']);
if(!preg_match("/^[a-zA-Z ]*$/",$class)){
$class_error ="Invalid Class";
}
}
if(empty($_POST['pschool'])){
$pschool =$_POST['pschool'];
}else{
$pschool =$_POST['pschool'];
}
if(empty($_POST['father'])){
$father_error="Father Name is Required";
}else{
$father =test_input($_POST['father']);
if(!preg_match("/^[a-zA-Z ]*$/",$father)){
$father_error ="Please check name field";
}
}
if(empty($_POST['father_occ'])){
$father_occ_error="Father Occupation is Required";
}else{
$father_occ =test_input($_POST['father_occ']);
if(!preg_match("/^[a-zA-Z ]*$/",$father_occ)){
$father_occ_error ="invalid Occupation";
}
}
if(empty($_POST['father_addr'])){
$father_addr_error="Father Address is Required";
}else{
$father_addr =$_POST['father_addr'];
}
if(empty($_POST['father_phone'])){
$father_phone_error="Required";
}else{
$father_phone =$_POST['father_phone'];
if(!preg_match("/^[0]\d{10}$/",$father_phone)){
$father_phone_error ="Invalid Phone no";
}
}
if(empty($_POST['mother'])){
$mother_error="Mother Name is Required";
}else{
$mother =test_input($_POST['mother']);
if(!preg_match("/^[a-zA-Z ]*$/",$mother)){
$mother_error ="Please check name field";
}
}
if(empty($_POST['mother_occ'])){
$mother_occ_error="Mother Occupation is Required";
}else{
$mother_occ =test_input($_POST['mother_occ']);
if(!preg_match("/^[a-zA-Z ]*$/",$mother_occ)){
$mother_occ_error ="invalid Occupation";
}
}
if(empty($_POST['mother_addr'])){
$mother_addr_error="Mother Address is Required";
}else{
$mother_addr =$_POST['mother_addr'];
}
if(empty($_POST['mother_phone'])){
$mother_phone_error="Required";
}else{
$mother_phone =$_POST['mother_phone'];
if(!preg_match("/^[0]\d{10}$/",$mother_phone)){
$mother_phone_error ="Invalid Phone no";
}
}
if(empty($_POST['health'])){
$health =$_POST['health'];
}else{
$health =$_POST['health'];
}
if($firstname_error =='' && $surname_error==''&& $dob_error=='' && $age_error=='' && $gender_error=='' &&$state_error==''&&$religion_error==''&& $class_error==''&&$father_error==''&&$father_occ_error==''&&$father_addr_error==''&&$father_phone_error==''&&$mother_error==''&&$mother_occ_error==''&&$mother_addr_error==''&&$mother_phone_error==''){
$check ="SELECT * FROM `admissions` WHERE `surname`='$surname' AND `firstname`='$firstname' AND `father_phone`='$father_phone' AND `dob`='$dob' AND `state`='$state' AND `tribe`='$tribe'";
$row_cnt =mysqli_num_rows($conn->query($check));
if($row_cnt > 0){
echo "<br><br><div class='container'>
<div class='row'>
<div class='col-md-8 '>
<div class='alert alert-success'>
<strong>Note!</strong> Your Application Has Already Been Submitted.
</div>
</div>
</div>
</div>";
}else{
$query = "INSERT INTO `admissions`(`id`, `surname`,`firstname`,`othername`, `dob`, `age`, `gender`, `state`, `tribe`, `religion`, `previous_school`, `class_of_admission`, `father_name`, `father_occup`, `father_addr`, `father_phone`, `mother_name`, `mother_occup`, `mother_addr`, `mother_phone`, `health_challenge`, `passport`,`status`) VALUES (NULL,'$surname','$firstname','$othername','$dob','$age','$gender','$state','$tribe','$religion','$pschool','$class','$father','$father_occ','$father_addr','$father_phone','$mother','$mother_occ','$mother_addr','$mother_phone','$health','$dbpath',0)";
$run =$conn->query($query);
if($run){
$fullname = $surname.' '.$firstname.' '.$othername;
echo "<script>console.log('Applied Successfully')</script>";
echo "<script>window.location.href ='generate.php?candidate=$fullname&dob=$dob&address=$father_addr&tribe=$tribe&age=$age';</script>";
}
}
}else{
echo "<script>console.log('error found')</script>";
}
}
?>
<div class="container">
<br>
<div class="col-md-10 offset-md-2 well">
<div class="row">
<center><h3><b>APPLICATION FORM</b></h3></center><br>
<form action="form.php" method="POST" enctype="multipart/form-data">
<div class="float-right" style="margin:20px;">
<label class=newbtn>
<img id="blah" src="http://placehold.it/140x140" >
<p>Upload Passport<br><span style="font-size:13px;color:green;">less than 100kb</span></p>
<span class="error"><?= $passport_error ?></span>
<input id="pic" class='pis' name="passport" onchange="readURL(this);" type="file" >
</label>
</div>
<div class="col-sm-12">
<div class="row">
<div class="col-sm-3 form-group">
<label>Surname</label>
<input type="text" placeholder="Enter Surname.." name="surname" value="<?=$surname?>" class="form-control">
<span class="error"><?= $fullname_error ?></span>
</div>
<div class="col-sm-3 form-group">
<label>Firstname</label>
<input type="text" placeholder="Enter Firstname Here.." name="firstname" value="<?=$firstname?>" class="form-control">
<span class="error"><?= $fullname_error ?></span>
</div>
<div class="col-sm-3 form-group">
<label>Othername</label>
<input type="text" placeholder="Enter Othername Here.." name="othername" value="<?=$othername?>" class="form-control">
<span class="error"><?= $fullname_error ?></span>
</div>
<div class="col-sm-3 form-group">
<label>Date of Birth</label>
<input type="Date" id="datepicker" class="form-control" name="dob" value="<?=$dob?>" placeholder="Choose">
<span class="error"><?= $dob_error ?></span>
</div>
<script>
$('.newbtn').bind("click" , function () {
$('#pic').click();
});
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#blah')
.attr('src', e.target.result);
};
reader.readAsDataURL(input.files[0]);
}
}
</script>
</div>
<div class="row">
<div class="col-sm-4 form-group">
<label>Age by September</label>
<input type="text" placeholder="Enter Age by September.." name="age" value="<?=$age?>" class="form-control">
<span class="error"><?= $age_error ?></span>
</div>
<div class="col-sm-4 form-group">
<label>Gender</label>
<select class="form-control" name="gender">
<option value="">Select Gender</option>
<option value="Male">Male</option>
<option value="Female">Female</option>
</select>
<span class="error"><?= $gender_error ?></span>
</div>
<div class="col-sm-4 form-group">
<label>State of Origin</label>
<select class="form-control" name="state">
<option value="">Select State of origin</option>
<option value="Abia">Abia</option>
<option value="Adamawa">Adamawa</option>
<option value="Akwa Ibom">Akwa Ibom</option>
<option value="Anambra">Anambra</option>
<option value="Bauchi">Bauchi</option>
<option value="Bayelsa">Bayelsa</option>
<option value="Benue">Benue</option>
<option value="Borno">Borno</option>
<option value="Cross River">Cross River</option>
<option value="Delta">Delta</option>
<option value="Ebonyi">Ebonyi</option>
<option value="Edo">Edo</option>
<option value="Ekiti">Ekiti</option>
<option value="Expatriate">Expatriate</option>
<option value="Enugu">Enugu</option>
<option value="FCT Abuja">FCT Abuja</option>
<option value="Gombe">Gombe</option>
<option value="Imo">Imo</option>
<option value="Jigawa">Jigawa</option>
<option value="Kaduna">Kaduna</option>
<option value="Kano">Kano</option>
<option value="Katsina">Katsina</option>
<option value="Kebbi">Kebbi</option>
<option value="Kogi">Kogi</option>
<option value="Kwara">Kwara</option>
<option value="Lagos">Lagos</option>
<option value="Nasarawa">Nasarawa</option>
<option value="Niger">Niger</option>
<option value="Ogun">Ogun</option>
<option value="Ondo">Ondo</option>
<option value="Osun">Osun</option>
<option value="Oyo">Oyo</option>
<option value="Plateau">Plateau</option>
<option value="Rivers">Rivers</option>
<option value="Sokoto">Sokoto</option>
<option value="Taraba">Taraba</option>
<option value="Yobe">Yobe</option>
<option value="Zamfara">Zamfara</option>
</select>
<span class="error"><?= $state_error ?></span>
</div>
</div>
<div class="row">
<div class="col-sm-4 form-group">
<label>Tribe</label>
<input type="text" placeholder="Tribe.." value="<?=$tribe?>" name="tribe" class="form-control">
<span class="error"><?=$tribe_error ?></span>
</div>
<div class="col-sm-4 form-group">
<label>Religion</label>
<select class="form-control" name="religion">
<option value="">Select Religion</option>
<option value="Islam">Islam</option>
<option value="Christianity">Christianity</option>
<option value="Others">Others</option>
</select>
<span class="error"><?= $religion_error ?></span>
</div>
<div class="col-sm-4 form-group">
<label>Class of Admission</label>
<select class="form-control" name="class">
<option value="">Select Class of Admission</option>
<option value="Islam">Pre Nursery</option>
<option value="Islam">Nursery One</option>
<option value="Islam">Nursery Two</option>
<option value="Islam">Primary One</option>
<option value="Islam">Primary Two</option>
<option value="Islam">Primary Three</option>
<option value="Islam">Primary Four</option>
<option value="Islam">Primary Five</option>
<option value="Islam">Primary Six</option>
</select>
<span class="error"><?= $class_error ?></span>
</div>
</div>
<div class="form-group">
<label>Previous School Attended</label>
<textarea placeholder="Previous School Attended.." rows="3" name="pschool" value="<?=$pschool?>" class="form-control"></textarea>
<span class="error"><?= $pschool_error ?></span>
</div>
<div class="row">
<div class="col-sm-4 form-group">
<label>Father Name</label>
<input type="text" placeholder="Enter Father Name.." name="father" value="<?=$father?>" class="form-control">
<span class="error"><?= $father_error ?></span>
</div>
<div class="col-sm-4 form-group">
<label>Father Occupation</label>
<input type="text" placeholder="Enter Father Occupation.." name="father_occ" value="<?=$father_occ?>" class="form-control">
<span class="error"><?= $father_occ_error ?></span>
</div>
<div class="col-sm-4 form-group">
<label>Father Address</label>
<input type="text" placeholder="Enter Father Address.." name="father_addr" value="<?=$father_addr?>" class="form-control">
<span class="error"><?= $father_addr_error ?></span>
</div>
</div>
<div class="row">
<div class="col-sm-4 form-group">
<label>Father Phone</label>
<input type="text" placeholder="Father Phone.." name="father_phone" value="<?=$father_phone?>" class="form-control">
<span class="error"><?= $father_phone_error ?></span>
</div>
</div>
<div class="row">
<div class="col-sm-4 form-group">
<label>Mother Name</label>
<input type="text" placeholder="Enter Mothers Name.." name="mother" value="<?=$mother?>" class="form-control">
<span class="error"><?= $mother_error ?></span>
</div>
<div class="col-sm-4 form-group">
<label>Mother Occupation</label>
<input type="text" placeholder="Enter Mothers Occupation.." name="mother_occ" value="<?=$mother_occ?>" class="form-control">
<span class="error"><?=$mother_occ_error ?></span>
</div>
<div class="col-sm-4 form-group">
<label>Mother Address</label>
<input type="text" placeholder="Enter Mothers Address.." name="mother_addr" value="<?=$mother_addr?>" class="form-control">
<span class="error"><?= $mother_addr_error ?></span>
</div>
</div>
<div class="row">
<div class="col-sm-4 form-group">
<label>Mother Phone</label>
<input type="text" placeholder="Enter Mothers Phone" name="mother_phone" value="<?=$mother_phone?>" class="form-control">
<span class="error"><?= $mother_phone_error ?></span>
</div>
</div>
<div class="form-group">
<label>Health Challenges</label>
<textarea placeholder="If any kindly state.." rows="3" name="health" value="<?=$health?>" class="form-control"></textarea>
</div>
<center><button type="submit" class="btn btn-danger">Preview & Submit</button></center>
</div>
</form>
</div>
</div>
</div>
<?php
include 'partials/script.php';
include 'includes/footer.inc.php';
?>