-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsanatize_validate.php
executable file
·85 lines (65 loc) · 1.76 KB
/
sanatize_validate.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
</head>
<body>
<form action="sanatize_validate.php" method="post">
<label for="">username</label>
<input type="text" name="username"><br>
<label for="">age</label>
<input type="text" name="age"><br>
<label for="">email</label>
<input type="text" name="email">
<input type="submit" name="login" value="login"><br>
</form>
</body>
</html>
<?php
if(isset($_POST["login"]))
{
// $username = $_POST["username"];
// echo "Hello joey";
// echo "Hello {$username}";
// Hello <script> alert("You have a VIRUS!"); </script>
$username = filter_input(
INPUT_POST,
"username",
FILTER_SANITIZE_SPECIAL_CHARS
);
if(empty($username))
{
echo "That username isn't valid<br>";
}
else {
echo "Your username is: {$username}<br>";
}
$age = filter_input(
INPUT_POST,
"age",
FILTER_SANITIZE_NUMBER_INT
);
if(empty($age))
{
echo "That age isn't valid<br>";
}
else {
echo "Your age is: {$age}<br>";
}
$email = filter_input(
INPUT_POST,
"email",
FILTER_SANITIZE_EMAIL
);
if(empty($email))
{
echo "That email wasn't valid<br>";
}
else {
echo "Your email is: {$email}<br>";
}
// echo "Hello {$username}. <br> You are {$age} years old. <br> Your email is {$email}";
}
?>