-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidation.php
107 lines (107 loc) · 3.79 KB
/
validation.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
<?php
// Checking whether the user has input a white spaces in the first and last name fields
if(empty(trim($fName)))
{
echo '<div class="alert alert-warning" role="alert">
<h5>!! First name is required, it cannot be blank !! </h5>
</div>';
$flag = false;
}
if(empty(trim($lName)))
{
echo '<div class="alert alert-warning" role="alert">
<h5>!! Last name is required, it cannot be blank !! </h5>
</div>';
$flag = false;
}
// Checking whether the year of birth being input is a blank.
if(empty($yob))
{
echo '<div class="alert alert-warning" role="alert">
<h5>!! Year of Birth is required, it cannot be empty !! </h5>
</div>';
$flag = false;
}
// Checking whether the value of year of birth is numeric or not.
elseif(!is_numeric($yob))
{
echo '<div class="alert alert-warning" role="alert">
<h5>!! Year of Birth can only be a numeric value, please !! </h5>
</div>';
$flag = false;
}
// I have done similar validation for studentId by checking whether its a blank or a non-numeric value
if(empty($studentId))
{
echo '<div class="alert alert-warning" role="alert">
<h5>!! Student ID is required, it cannot be empty !! </h5>
</div>';
$flag = false;
}
elseif(!is_numeric($studentId))
{
echo '<div class="alert alert-warning" role="alert">
<h5>!! Student ID can only be a numeric value, please !! </h5>
</div>';
$flag = false;
}
// Checking whether the college name, address, city, postal code is empty
if(empty(trim($cName)))
{
echo '<div class="alert alert-warning" role="alert">
<h5>!! College name is required, it cannot be blank !! </h5>
</div>';
$flag = false;
}
if(empty(trim($add)))
{
echo '<div class="alert alert-warning" role="alert">
<h5>!! Address line cannot be empty !! </h5>
</div>';
$flag = false;
}
if(empty(trim($city)))
{
echo '<div class="alert alert-warning" role="alert">
<h5>!! City name is required, it cannot be blank !! </h5>
</div>';
$flag = false;
}
if(empty(trim($pCode)))
{
echo '<div class="alert alert-warning" role="alert">
<h5>!! Postal code is required, it cannot be empty !! </h5>
</div>';
$flag = false;
}
// since both the stateId and residenceId represent a numeric value associated with the text being displayed
// So I validated it by checking whether its a blank or non-numeric type
if(empty($stateId))
{
echo '<div class="alert alert-warning" role="alert">
<h5>!! State Id is required, it cannot be empty !! </h5>
</div>';
$flag = false;
}
elseif(!is_numeric($stateId))
{
echo '<div class="alert alert-warning" role="alert">
<h5>!! State Id can only be a numeric value, please !! </h5>
</div>';
$flag = false;
}
if(empty($residenceId))
{
echo '<div class="alert alert-warning" role="alert">
<h5>!! Residence Id is required, it cannot be empty !! </h5>
</div>';
$flag = false;
}
elseif(!is_numeric($residenceId))
{
echo '<div class="alert alert-warning" role="alert">
<h5>!! Residence Id can only be a numeric value, please !! </h5>
</div>';
$flag = false;
}
?>