PHP Classes

File: formtest.php

Recommend this page to a friend!
  Classes of Jelte Werkhoven  >  Form and SQL generator, CSS compatible  >  formtest.php  >  Download  
File: formtest.php
Role: ???
Content type: text/plain
Description: On request, this is a small example file to go with the class
Class: Form and SQL generator, CSS compatible
Author: By
Last change:
Date: 16 years ago
Size: 1,839 bytes


Class file image Download

# These are the values for the Selectbox
$Values = array(1 => "Da", 2 => "Ka", 3 => "La", 4 => "Za");


$TestForm = new Form;

#A bit unelegant, but necessary to append the date-info of the three selectboxes into one
# date again. 
if ($Submit)
	 $Date = $Year.$Month.$Day;

$TestForm -> StartForm("Testje", $PHP_SELF, $ShowVal);

$TestForm -> AddHTML("This is your basic textfield", "LabelText", "Label");
$TestForm -> TextField("TextTest", $TextTest);

$TestForm -> AddHTML("This is, well, your basic textarea", "LabelArea", "Label");
$TestForm -> TextArea("AreaTest", $AreaTest);

$TestForm -> AddHTML("Getting the picture yet?");
$TestForm -> SelectBox("SelectTest", $Values, $SelectTest);

$TestForm -> AddHTML("This actually does something... select it, and the values of the field will be
			shown after the submit", "LabelCheck", "Label");
$TestForm -> CheckBox("ShowVal", $ShowVal);

$TestForm -> AddHTML("Add a date ....", "LabelDate", "Label");
$TestForm -> DateField("Dates", $Date);

$TestForm -> AddHTML("And presto, your basic form. Now submit", "LabelSubmut", "Label");
$TestForm -> Submit("Submit", "Submit");

$TestForm -> EndForm();

if ($Submit)
	 $TestForm -> SQLInsert("FooBarTableName");
	 ### Normally, I'd feed the line of SQL to my database class here
<!-- Here we can start the HTML and print the PHP objects. I like to keep the main body of PHP 
	and the HTML page separated for those poor webdesigners =) -->
<?print $TestForm -> JavaScript?>

<!-- Put the CSS stuff here, e.g. for the AddHTML thingies, which are both labelled and id'd -->

<?print $TestForm -> RawHTML;

if ($Submit)
	 print $TestForm -> SQL;