-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdemo.php
37 lines (29 loc) · 1 KB
/
demo.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
<?php
require_once 'class.validator.php';
$v = new Validator;
$rules = [
'email' => 'required|email:zayn.com',
'password' => 'required|min_length:8|max_length:30',
'environment' => 'required|white_list:admin,user,guest',
'file' => 'f_required|f_types:jpg,bmp,png'
];
$v->validate($_POST, $rules);
$v->is_valid ?: $v->show_errors(['id' => 'errors', 'class' => 'errors'], TRUE);
echo "<pre>", print_r($_POST), "</pre>";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Validator Demo</title>
</head>
<body>
<form action="demo.php" method="POST" enctype="multipart/form-data" novalidate>
<input type="hidden" name="environment" value="admin"> <br>
Email: <input type="email" name="email"> <br>
Password: <input type="password" name="password"> <br>
<input type="file" name="file"> <br>
<input type="submit" value="submit">
</form>
</body>
</html>