-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm.php
More file actions
50 lines (42 loc) · 1.08 KB
/
Form.php
File metadata and controls
50 lines (42 loc) · 1.08 KB
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
<?php
include(FORMS . 'inputs/InputHolder.php');
include(FORMS . 'inputs/LabelCombobox.php');
include(FORMS . 'inputs/LabelFilebox.php');
include(FORMS . 'inputs/LabelTextbox.php');
include(FORMS . 'inputs/LabelTextarea.php');
include(FORMS . 'inputs/HiddenInput.php');
class Form
{
public $name;
public $action;
public $method;
public $title;
public function __construct($name, $action, $method = 'POST')
{
$this->name = $name;
$this->action = $action;
$this->input_list = array();
}
public function add_input($input)
{
array_push($this->input_list, $input);
}
public function add_header($header)
{
$this->header = $header;
}
public function print_code()
{
echo "<form id=\"$this->name\" enctype=\"multipart/form-data\" action=\"$this->action\" method=\"$this->method\">\n";
if(isset($this->header))
{
echo "<header>$this->header</header>";
}
foreach($this->input_list as $input)
{
$input->print_code();
}
echo '<div><input type="submit" value="send"/></div>' . "\n";
echo "</form>\n";
}
}