sloppycode.net
FormTemplate class
A small class for simplyfying HTML forms in PHP.
Home
›
Code snippets
›
PHP
›
FormTemplate class
Download source + documentation
Form generation and validation class. Uses flat file to describe the form including all display options and validation. Validation can be either server-side or client-side via javascript. Uses HtmlTable class, also available from snippets library and is included in the download.
This class like all PHP classes on sloppycode.net was made in PHP 3.x or 4, so unfortunately isn't guaranteed to be error free anymore.
<html> <head> <title>Form Template Example</title> <STYLE type="text/css" media="screen"> BODY,TD,SELECT,TEXTAREA,INPUT,PRE{ font: 9pt "arial", "helvetica", sans-serif;} TD.formInput { background: #ffffff; } TD.formName { background: #ffffff; text-align: right;} .formButton { width:75px} TD.formSeperator { background: #ffffff;} TD.formBackground { background: #000000; } TD.formError { color: red; background: #ffffff; } TD.formName { font-weight: bold; color: #666666; } </STYLE> </head> <body> <? require("clsFormTemplate.php"); $form = new FormTemplate("example.conf"); // Change the outer table look (see the CSS up the top too) $form->table_style = 'BORDER="0" CELLPADDING="3" CELLSPACING="0" VALIGN="top"'; if (isset($HTTP_POST_VARS) && ($HTTP_POST_VARS['form_action'] =='ok')) { $form->validate($HTTP_POST_VARS); $form->make_table(); // If there are errors if ($form->validation_error) { echo "<H2>Validation Error</H2>"; echo $form->table; } else{ // Otherwise do something echo "Form validated okay"; } } else { $form->make_table(); echo $form->table; } ?> </body> </html>
{Name}
Says:
{Date}
{Text}
› Home
› C#
› Snippets
› Articles
› Tools
› Taglines
› ASP
› Dictionary Object
› FSO
› Unix cheat sheet
› Gaming
› CSS
› Yak
› Umbraco
› About
› Contact
› Privacy
› Projects
› Search
› Sitemap
Buy on Amazon
Buy on Amazon
Buy on Amazon
Buy on Amazon