-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
108 lines (98 loc) · 1.66 KB
/
functions.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
<?php
//$username = "90103518b";
//validateStudentUsername($username);
function validateStudentUsername($string)
{
if(strlen($string) == 9 && !preg_match('/[^a-zA-Z\d]/', $string))
{
$splitstring = str_split($string);
if(is_numeric($splitstring[0]))
{
if(preg_match_all( "/[0-9]/", $string) == 9)
{
//echo "Valid Student ID";
return true;
exit();
}
else
{
//echo "Not up to 9 digits";
return false;
exit();
}
}
else if ($splitstring[0] == n || $splitstring[0] == N)
{
if(preg_match_all( "/[0-9]/", $string) == 8)
{
//echo "Valid student ID";
return true;
exit();
}
else
{
//echo "Not up to 8 digits";
return false;
exit();
}
}
else
{
//echo "First character problems";
return false;
exit();
}
}
else
{
//echo "Length problems";
return false;
exit();
}
}
function validateItemName($string)
{
if(strlen($string) < 3 || strlen($string) > 20)
{
return false;
exit();
}
return true;
}
function validateSerialNo($string)
{
if(!is_numeric($string) || strlen($string) != 6)
{
return false;
exit();
}
return true;
}
function validateAdminUsername($string)
{
if(strlen($string) < 6 || strlen($string) > 16 || preg_match('/[^a-zA-Z\d]/', $string))
{
return false;
exit();
}
return true;
}
function nameValidation($string)
{
if(strlen($string) < 2 || strlen($string) > 10 || preg_match('/[^a-zA-Z\d]/', $string) || preg_match_all( "/[0-9]/", $string) > 0)
{
return false;
exit();
}
return true;
}
function passwordValidation($string)
{
if(strlen($string) < 8 || strlen($string) > 15)
{
return false;
exit();
}
return true;
}
?>