forked from joshcanhelp/php-form-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
116 lines (98 loc) · 2.34 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
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>PHhpFormBuilder test</title>
</head>
<body>
<?php
require_once('PhpFormBuilder.php');
/*
Create a new instance
Pass in a URL to set the action
*/
$form = new PhpFormBuilder();
/*
Form attributes are modified with the set_att function.
First argument is the setting
Second argument is the value
*/
/*
* $form->set_att('method', 'post');
* $form->set_att('enctype', 'a_contact_form');
* $form->set_att('markup', 'html');
* $form->set_att('class', 'class_1');
* $form->set_att('class', 'class_2');
* $form->set_att('id', 'a_contact_form');
* $form->set_att('novalidate', true);
* $form->set_att('add_honeypot', false);
* $form->set_att('add_nonce', 'a_contact_form');
* $form->set_att('form_element', false);
*/
$form->set_att('enctype', 'multipart/form-data');
$form->set_att('method', 'post');
/*
Uss add_input to create form fields
First argument is the name
Second argument is an array of arguments for the field
Third argument is an alternative name field, if needed
*/
$form->add_input('Name', array(
), 'contact_name');
$form->add_input('Email', array(
'type' => 'email'
), 'contact_email');
$form->add_input('Filez', array(
'type' => 'file'
), 'filez_here');
$form->add_input('Reason for contacting', array(
'type' => 'checkbox',
'options' => array(
'say_hi' => 'Just saying hi!',
'complain' => 'I have a bone to pick',
'offer_gift' => 'I\'d like to give you something neat',
)
));
$form->add_input('Bad Headline', array(
'type' => 'radio',
'options' => array(
'say_hi_2' => 'Just saying hi! 2',
'complain_2' => 'I have a bone to pick 2',
'offer_gift_2' => 'I\'d like to give you something neat 2',
)
));
$form->add_input('Reason for contact', array(
'type' => 'select',
'options' => array(
'' => 'Select...',
'say_hi' => 'Just saying hi!',
'complain' => 'I have a bone to pick',
'offer_gift' => 'I\'d like to give you something neat',
)
));
$form->add_input('Question or comment', array(
'required' => true,
'type' => 'textarea',
'value' => 'Type away!'
));
$form->add_inputs(array(
array('Field 1'),
array('Field 2'),
array('Field 3')
));
/*
Create the form
*/
$form->build_form();
/*
* Debugging
*/
echo '<pre>';
print_r( $_REQUEST );
echo '</pre>';
echo '<pre>';
print_r( $_FILES );
echo '</pre>';
?>
</body>
</html>