-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvalidation.php
More file actions
46 lines (40 loc) · 840 Bytes
/
validation.php
File metadata and controls
46 lines (40 loc) · 840 Bytes
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
<?php
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
function validate_name($name){
if (! preg_match("/^[a-zA-Z-' ]*$/",$name) ) {
$Msg = "Only alphabets and whitespace are allowed.";
} else {
$Msg = "good";
}
return $Msg;
}
function validate_roll($roll){
if (! preg_match ("/^[0-9]*$/", $roll) ) {
$Msg = "Only Numbers are allowed.";
} else {
$Msg = "good";
}
return $Msg;
}
function validate_email($email){
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$Msg = "Invalid email format";
} else {
$Msg = "good";
}
return $Msg;
}
function validate_mob($mob){
if (! preg_match ("/^[0-9]*$/", $mob) ) {
$Msg = "Only numbers are allowed.";
} else {
$Msg = "good";
}
return $Msg;
}
?>