-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathform.php
61 lines (58 loc) · 1.6 KB
/
form.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
<?php
require 'validator.php';
// this part should be in the template controller or View
if(isset($_POST['submit'])) {
$validationRules = array("name" => "required|string|mini:8|maxi:20",
"email" => "required|email|mini:8|maxi:30",
"password" => "required|mini:8",
"user_type"=> "required|int");
#create a vaildator object
$validate = new Validator;
$validate->validate($_POST,$validationRules);
if(!$validate->isPass()){
$validate->getErrors();
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-4">
<h3> Test Form</h3>
<form method="post" action="form.php" class="form-horizental">
<div class="form-group">
<label >Name : </label>
<input type="text" name="name" class="form-control">
</div>
<div class="form-group">
<label >Email : </label>
<input type="email" name="email" class="form-control">
</div>
<div class="form-group">
<label >Password</label>
<input type="password" name="password" class="form-control">
</div>
<div class="form-group">
<label >Type</label>
<select name="user_type" class="form-control">
<option value="1">Super User</option>
<option value="2"> Admin </option>
<option value="3"> User </option>
</select>
</div>
<div class="form-group">
<label > submit</label>
<input type="submit" name="submit" value="login" class="btn btn-default">
</div>
</form>
</div>
</div>
</div>
</body>
</html>