-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSantize Input.php
33 lines (30 loc) · 943 Bytes
/
Santize Input.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge" <meta name="viewport" content="width=device-width >
<title>Document</title>
</head>
<body>
<form action=" index.php" method="post">
username:<br>
<input type="text" name="username"><br>
age:<br>
<input type="text" name="age"><br>
email:<br>
<input type="text" name="email"><br>
<input type="submit" name="login" value="log">
</form>
</body>
</html>
<?php
if (isset($_POST["login"])) {
$username = filter_input(INPUT_POST, "username", FILTER_SANITIZE_SPECIAL_CHARS);
$age = filter_input(INPUT_POST, "age", FILTER_SANITIZE_NUMBER_INT); // FILTER_VALIDATE_INT , Can also be used
$email = filter_input(INPUT_POST, "email", FILTER_SANITIZE_EMAIL);
if (empty($email)) {
echo "That email wasn't valid";
} else
echo "Your email is: {$email}";
}
?>