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
|
<?php
/*
* Model web-forms and simplify the process of accepting, validating, and sanitizing input
*/
class Form
{
/*
* Constructor
*/
function __construct()
{
$this->textFields = array();
$this->numbFields = array();
$this->enumFields = array();
$this->errorlist = array();
$this->warninglist = array();
$this->noticelist = array();
}
/*
* Add new text field to the form
*/
function field_text($name, $req = true)
{
if ($req !== true)
$req = false;
$this->textFields[] = array(
'name' => $name,
'req' => $req
);
}
/*
* Add new numeric field to the form
*/
function field_numeric($name, $req = true, $integer = true, $min = null, $max = null)
{
if ($req !== true)
$req = false;
if ($integer !== true)
$integer = false;
$this->numbFields[] = array(
'name' => $name,
'req' => $req,
'int' => $integer,
'min' => $min,
'max' => $max
);
}
/*
* Add new enumeration field to the form
*/
function field_enum($name, $req = true, $values)
{
if ($req !== true)
$req = false;
$this->enumFields[] = array(
'name' => $name,
'req' => $req,
'vals' => $values
);
}
}
?>
|