forked from ASoares/PHP-Form-Validation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
132 lines (110 loc) · 2.72 KB
/
index.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
include 'validFluent.php';
if (empty($_POST))
{
// setting some start values
$vf = new ValidFluent(array());
$vf->name('userName')
->setValue('legolas')
->setError('ooopps, name already in use!');
}
else
{
//validate $_POST data
$vf = new ValidFluent($_POST);
$vf->name('email')
->required('you need to type someting here')
->email()
->minSize(8);
$vf->name('date')
->required()
->date();
//can also be used like this....
if ($vf->name('userName')
->alfa()
->minSize(3)
->maxSize(12)
->name('choseOne')
->oneOf('en:es:fr:pt:other')
->name('password1')
->required()
->minSize(3)
->alfa()
->name('password2')
->required()
->equal($_POST['password1'], 'passwords didnt match')
->isGroupValid())
echo "Validation Passed \n";
else
echo "validation errors";
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
.error
{
color:red;
}
</style>
<title></title>
</head>
<body>
<form method="POST">
<label for="email">EMAIL</label>
<input type="text" name="email"
value="<?php echo $vf->getValue('email'); ?>"
/>
<span class="error">
<?php echo $vf->getError('email'); ?>
</span>
<br><br>
<label for="date">DATE</label>
<input type="text" name="date"
value="<?php echo $vf->getValue('date'); ?>"
/>
<span class="error">
<?php echo $vf->getError('date'); ?>
</span>
<br><br>
<label for="userName">User Name</label>
<input type="text" name="userName"
value="<?php echo $vf->getValue('userName'); ?>"
/>
<span class="error">
<?php echo $vf->getError('userName'); ?>
</span>
<br><br>
<label for="date">language 'pt' 'en' 'es' 'fr' or 'other'</label>
<input type="text" name="choseOne"
value="<?php echo $vf->getValue('choseOne'); ?>"
/>
<span class="error">
<?php echo $vf->getError('choseOne'); ?>
</span>
<br><br>
<label for="password1">Password</label>
<input type="text" name="password1"
value="<?php echo $vf->getValue('password1'); ?>"
/>
<span class="error">
<?php echo $vf->getError('password1'); ?>
</span>
<br><br>
<label for="password2">Confirm Password</label>
<input type="text" name="password2"
value="<?php echo $vf->getValue('password2'); ?>"
/>
<span class="error">
<?php echo $vf->getError('password2'); ?>
</span>
<br><br>
<input type="submit" />
</form>
<?php
// put your code here
?>
</body>
</html>