There are many form generators around, this is not one. This little proggie takes the pain out of form fillers. It allows you to create dynamic dropdowns, checkboxes and radio buttons. You can create the whole form or just insert a button or dropdown in your form. FF_Form takes values from a mysql db and inserts these into a checkbox, form or dropdown. This is very handy for searchforms, requests and many other forms.
[ index ]This would probably equal to a GNU Lesser General Public License ( http://www.opensource.org/licenses/lgpl-license.php )in other words this costs nothing, you are free to use, change , abuse this code as long as you maintain a copyright notice in the code. If you use or change the code, it would be nice if you sent me the changed code and/or the URL of where you use it. All warranties are excluded.
[ index ]
To install FF_Form all you need to do is to upload the:
- ff_form.class.php, to your inc directory chmod it.
- connect_mysql.php, to your inc directory ( make sure to configure before uploading)
- style.css to the location where you keep your .css
- ff_form.sql to your MySql database
- You need to configure your MySql connection data in the file connect_mysql.php in the inc folder.
- The second thing to configure is to include the following files on the page your form will be displayed on: connect_mysql.php, ff_form.class.php and style.css, like this:
<?php
include ("path_to_your_inc_folder/ff_form.class.php");
include ("path_to_your_inc_folder/connect_mysql.php");
?>
and the stylesheet in the head section of your page like this
<link rel="stylesheet" type="text/css" href="style.css"/>
- Next initialize the form like this
$ff = new ff_form; (ff can be a combination of your choice but should be at least 2 letters and not more than 5 the combination must be unique for each form)
- Now set the call to the first function. Which will mainly set css classes and as default uses preset names
the function call looks like this with the preset default values:
echo $ff->ff_form
(
'heading_radio', -- This is the group header for radio buttons with a table
'label_lr', -- label for the radio button where the label is left in a table
'label_select', -- label for the select field in a table
'heading_select', -- heading for a group of select fields in a table
'data_select', -- the actual dropdown field in a table or without table
20, -- limit the result in a selectbox, radio button group or check box
'label_rl', -- label for the radio button where the label is right in a table
'heading_check', -- heading for checkbox groups in table
'label_lc', -- label for checkboxes where label left in table
'label_cl', -- label for checkboxes where label right in table
'tbl', -- table class name
'hsn', -- Heading for select groups no table
'lrn', -- radio button label left no table
'rln', -- radio button label right no table
'lsn', -- label select box no table
'lcn', -- checkbox label left no table
'cln' -- checkbox label right no table
);
Here I will try to explain how to set the function calls so that you get the results you want, using tables.
First set the variable for the form and table like this (xx must be changed to your letter combination:
echo $xx->ff_head
(
'formname',-- name of the form
'filename.php', -- action
'get' -- method
);
Now set the table variables.
echo $xx->ff_tbl_head
(
'form_1' -- the name of the table
);
best you also set the closing tags now
echo $xx->ff_tbl_foot();
echo $xx->ff_foot();
so your form will look something like this:
$xx = new ff_form;
echo $xx->ff_form ('heading_radio', 'label_lr', 'label_select', 'heading_select', 'data_select', '20' , 'label_rl', 'heading_check', 'label_lc', 'label_cl', 'tbl', "hsn", 'lrn','rln', 'lsn', 'lcn', 'cln');
echo $xx->ff_head ( 'formname', 'filename.php', 'get' );
echo $xx->ff_tbl_head('form_1');
!--- All follwing function calls are inserted here---!
echo $xx->ff_tbl_foot();
echo $xx->ff_foot();
For this part of the ff_form if you use tables the table is built up like this:
<form>
<tr>
<td>label or field </td><td>label or field </td>
</tr>
</form>
Just insert this line and complete the variables as explained. The label will apear on the left of the select box.
echo $xx->fft_select('label','MySQL_table' ,'MySQL_column', 'group_label');
[ index ]
For this there are two different functions one with the label on the left
echo $xx->fft_lr('heading for the group','MySQL_table' ,'MySQL_column', 'value to be prechecked ('' for none)', 'name of group usually table name');
the other on the right
echo $xx->fft_rl('heading for the group','MySQL_table' ,'MySQL_column', 'value to be prechecked ('' for none)', 'name of group usually table name');
[ index ]
For this there are two different functions one with the label on the left
echo $xx->fft_lc('heading for the group','MySQL_table' ,'MySQL_column', 'value to be prechecked ('' for none)', 'value2 to be prechecked', 'value3 to be prechecked', 'value4 to be prechecked', 'value5 to be prechecked', 'name of group usually table name');
the other on the right
echo $xx->fft_cl('heading for the group','MySQL_table' ,'MySQL_column', 'value to be prechecked ('' for none)', 'value2 to be prechecked', 'value3 to be prechecked', 'value4 to be prechecked', 'value5 to be prechecked', 'name of group usually table name');
[ index ]
Here I will try to explain how to set the function calls so that you get the results you want.
[ index ]First set the variable for the form like this (xx must be changed to your letter combination:
echo $xx->ff_head
(
'formname',-- name of the form
'filename.php', -- action
'get' -- method
);
best you also set the closing tag now
echo $xx->ff_foot();
so your form will look something like this:
$xx = new ff_form;
echo $xx->ff_form ('heading_radio', 'label_lr', 'label_select', 'heading_select', 'data_select', '20' , 'label_rl', 'heading_check', 'label_lc', 'label_cl', 'tbl', "hsn", 'lrn','rln', 'lsn', 'lcn', 'cln');
echo $xx->ff_head ( 'formname', 'filename.php', 'get' );
Just insert this line and complete the variables as explained. The label will apear on the left of the select box.
echo $xx->fft_select('label','MySQL_table' ,'MySQL_column', 'group_label');
[ index ]
For this there are two different functions one with the label on the left
echo $xx->fft_lr('heading for the group','MySQL_table' ,'MySQL_column', 'value to be prechecked ('' for none)', 'name of group usually table name');
the other on the right
echo $xx->fft_rl('heading for the group','MySQL_table' ,'MySQL_column', 'value to be prechecked ('' for none)', 'name of group usually table name');
[ index ]
For this there are two different functions one with the label on the left
echo $xx->fft_lc('heading for the group','MySQL_table' ,'MySQL_column', 'value1 to be prechecked ('' for none)', 'value2 to be prechecked', 'value3 to be prechecked', 'value4 to be prechecked', 'value5 to be prechecked', 'name of group usually table name');
the other on the right
echo $xx->fft_cl('heading for the group','MySQL_table' ,'MySQL_column', 'value to be prechecked ('' for none)', 'value2 to be prechecked', 'value3 to be prechecked', 'value4 to be prechecked', 'value5 to be prechecked', 'name of group usually table name');
[ index ]
Please note that: