forked from Ahwanpradhan/SS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidation.php
More file actions
57 lines (55 loc) · 1.25 KB
/
Copy pathvalidation.php
File metadata and controls
57 lines (55 loc) · 1.25 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
<?php
$nameErr = $emailErr = $mobileErr = "";
$user_Name = $user_Mail = $user_Mobile = "";
function test_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
if(isset($_POST['user_submit']))
{
//Name Validation
if (empty($_POST["user_name"]))
{
$nameErr = "Name is required";
}
else
{
$user_Name = test_input($_POST["user_name"]);
// check if name only contains letters and whitespace
if (!preg_match("/^[a-zA-Z ]*$/",$user_Name))
{
$nameErr = "Only letters and white space allowed";
}
}
//Email Validation
if (empty($_POST["user_email"]))
{
$emailErr = "Email is required";
}
else
{
$user_Email = test_input($_POST["user_email"]);
// check if e-mail address is well-formed
if (!filter_var($user_Email, FILTER_VALIDATE_EMAIL))
{
$emailErr = "Invalid email format";
}
}
if (empty($_POST["user_mobile"]))
{
$mobileErr = "Mobile is required";
}
else
{
$user_Mobile = test_input($_POST["user_mobile"]);
// check if mobile is well-formed
if(!preg_match("/^[0-9]*$/", $user_Mobile))
{
$mobileErr = "Enter a valid Mobile number";
}
}
}
?>