This class was created by Adam Parker & Oliver Leuyim Angel.
include_once ('class.forms.php');This will start a form that will submit to itself via post. You can customize these aspects if you want, below is an example of full customization.
$form = new buildForm();
$form->open();
include_once ('class.forms.php');Using that code will start a form (with javascript validation enabled) that will post to the file login.php.
$form = new buildForm();
$form->action = 'post';
$form->method = 'login.php';
$form->validate = true;
$form->open();
include_once ('class.forms.php');This will associate a mySQL table with this form allowing you to save to it
$form = new buildForm();
$form->database = array('table' => 'account');
if($_POST) { echo $form->processSubmitted($_POST, $_FILES); }
$form->action = 'post';
$form->method = 'login.php';
$form->validate = true;
$form->open();
include_once ('class.forms.php');This will associate a mySQL table with this form allowing you to update it and pull information from the table
$form = new buildForm();
$form->database = array('table' => 'account', 'where' => 'userid = "1"');
if($_POST) { echo $form->processSubmitted($_POST, $_FILES); }
$form->action = 'post';
$form->method = 'login.php';
$form->validate = true;
$form->open();
$form->upload(array('name' => 'photo'));The only thing we are doing here is creating a new upload area called 'photo'. We can customize this in a number of ways:
$form->upload(array('name' => 'photo', 'size' => '20', 'maxsize' => '10000', 'allowed' => 'jpg,gif,png', 'resize' => '500x500', 'dir' => '/home/uploads/', html => 'style="font-size: 0.9em;"'));
Explination of Options:
Option What it Does name: Name of field size: Set the size tag in the file box (width) maxsize: The largest file size you'll accept (in bytes) allowed: A comma delimited list of allowed file types resize: The deminitions to resize the image (WIDTHxHEIGHT). Will resize proportionally. dir: Full path to the directory you wish to upload your file (other than default) html: Add advanced commands directly into the tag
$form->text(array('name' => 'username'));The only thing we are doing here is creating a new text field called 'username'. We can customize this in a number of ways:
$form->text(array('name' => 'username', size => '50', validate => 'Please enter your username', html => 'style="font-size: 0.9em;"'));
Explination of Options:
Option What it Does name: Name of field size: Set the size tag in the input box validate: Enables validation for this field and sets message to inform the user value: (1) Preset value for the field
(2) To pre-populate with GET data, set value to [get]
(3) To pre-populate with POST data, set value to [post]
(4) To pre-populate with SQL data, set value to [sql]html: Add advanced commands directly into the tag
$form->password(array('name' => 'password'));The only thing we are doing here is creating a new password field called 'password'. We can customize this in a number of ways:
$form->password(array('name' => 'password', size => '50', validate => 'Please enter your password', html => 'style="font-size: 0.9em;"'));
Explination of Options:
Option What it Does name: Name of field size: Set the size tag in the input box< validate: Enables validation for this field and sets message to inform the user value: (1) Preset value for the field
(2) To pre-populate with GET data, set value to [get]
(3) To pre-populate with POST data, set value to [post]
(4) To pre-populate with SQL data, set value to [sql]html: Add advanced commands directly into the tag
$form->hidden(array('name' => 'userid'));The only thing we are doing here is creating a new hidden field called 'userid'. We can customize this in a number of ways:
$form->hidden(array('name' => 'userid', 'value' => '[get]'));
Explination of Options:
Option What it Does name: Name of field value: (1) Preset value for the field
(2) To pre-populate with GET data, set value to [get]
(3) To pre-populate with POST data, set value to [post]
(4) To pre-populate with SQL data, set value to [sql]
$form->textarea(array('name' => 'comments'));The only thing we are doing here is creating a new textarea called 'comments'. We can customize this in a number of ways:
$form->textarea(array('name' => 'comments', 'rows' => '10', 'cols' => '30', 'value' => '[post]', 'validate' => 'Please enter some comments', 'html' => 'style="font-size: 1.1em;"'));
Explination of Options:
Option What it Does name: Name of field rows: Set the row tag in the textarea cols: Set the cols tag in the textarea validate: Enables validation for this field and sets message to inform the user value: (1) Preset value for the field
(2) To pre-populate with GET data, set value to [get]
(3) To pre-populate with POST data, set value to [post]
(4) To pre-populate with SQL data, set value to [sql]html: Add advanced commands directly into the tag
$form->radio(array('name' => 'gender', 'value' => 'male')); $form->radio(array('name' => 'gender', 'value' => 'female'));The only thing we are doing here is creating two new radio button called 'gender', with one value 'male' the other 'female'. We can customize this in a number of ways:
$form->radio(array('name' => 'gender', 'value' => 'male', 'checked' => 'male', 'label' => 'Male', 'html' = > 'style="font: Tahoma;"', 'validate' => 'Please select a gender'));
Explination of Options:
Option What it Does name: Name of field value: Value of field if selected label: Add a label for this field checked: (1) Marks item as checked if value is equal to specified string
(2) To check against GET data, set value to [get]
(3) To check against POST data, set value to [post]
(4) To check against SQL data, set value to [sql]validate: Enables validation for this field and sets message to inform the user html: Add advanced commands directly into the tag
$form->checkbox(array('name' => 'tv', 'value' => 'yes')); $form->checkbox(array('name' => 'tv', 'value' => 'no'));The only thing we are doing here is creating two checkbox, with one value 'yes' the other 'no'. We can customize this in a number of ways:
$form->checkbox(array('name' => 'tv', 'value' => 'yes', 'checked' => '[post]', 'label' => 'Yes', 'html' = > 'style="font: Tahoma;"', 'validate' => 'Please select if you have a TV'));
Explination of Options:
Option What it Does name: Name of field value: Value of field if selected label: Add a label for this field checked: (1) Marks item as checked if value is equal to specified string
(2) To check against GET data, set value to [get]
(3) To check against POST data, set value to [post]
(4) To check against SQL data, set value to [sql]validate: Enables validation for this field and sets message to inform the user html: Add advanced commands directly into the tag
Select Box with Values from Array
$aryValues = array('one' => '1 Computer', 'two' => '2 Computers', 'three' => '3 Computers');
$form->select(array('name' => 'numberofcomputers', 'value' => $aryValues, 'selected' => '[get]', 'html' => 'style="width:100%;"'));
This will load the values from $aryValues into the select box. In the first part of the array 'one' would be the value and '1 Computer' would be the displayed text for that option.
Select Box with Values from Command Deliminated List
$form->select(array('name' => 'numberofcomputers', 'value' => '1 Computer, 2 Computers, 3 Computers', 'selected' => '[get]', 'html' => 'style="width:100%;"'));
This will load the values '1 Computer, 2 Computers, 3 Computers' into the select box. The value for the first option will be '1_Computer' and the display text will be '1 Computer'
Select Box with Values from Number Range
$form->select(array('name' => 'numberofcomputers', 'value' => '1~3~Computers', 'selected' => '[get]', 'html' => 'style="width:100%;"'));
This will process the values '1~3~Computers' into the select box. It will automatically create a option for all the numbers between '1' and '3' and will contain the suffix 'Computers' in the display text
Explination of Options:
Option What it Does name: The name of the button value: (1) Populate values and options according to an array. Example: $aryValues = array('one' => '1 Computer', 'two' => '2 Computers');
(2) Populate values and options according to a comma delimited list
(3) Populate values and options based on a range of numbers: Example 1: 2000~2015 (Starts at 2000 and will end at 2015)
Example 2: 2000-2015~Years (Starts at 2000 and will end at 2015. Will display suffix of 'Years' after each option)
(4) Populate with states use: [states] (only for the version in php v5)
(5) Populate with countries use: [countries] (only for the version in php v5)
(6) Populate with Mexico states use: [estados] (only for the version in php v5)validate: Enables validation for this field and sets message to inform the user selected: (1) Marks item as selected if value is equal to specified string
(2) To check against GET data, set value to [get]
(3) To check against POST data, set value to [post]
(4) To check against SQL data, set value to [sql]html: Add advanced commands directly into the tag
$form->submit();This button can be customized in a number of ways:
$form->submit(array('value' => 'Submit Contact Form', 'html' => 'style="font: bold 12pt Tahoma;"');
Explination of Options:
Option What it Does value: The text to appear in this button html: Add advanced commands directly into the tag
$form->button(array('name' => 'checkForm'));This button can be customized in a number of ways:
$form->submit(array('name' => 'checkForm', 'value' => 'Check Form', 'html' => 'style="font: bold 12pt Tahoma;"'));
Explination of Options:
Option What it Does name: The name of the button value: The text to appear in this button html: Add advanced commands directly into the tag
$form->close();