PHP Classes

File: example_multiuse.php

Recommend this page to a friend!
  Classes of Thiemo Mättig  >  TM::Apeform  >  example_multiuse.php  >  Download  
File: example_multiuse.php
Role: Example script
Content type: text/plain
Description: How to use a form multiple times
Class: TM::Apeform
A very abstract web form builder and processor
Author: By
Last change: Accessible without user login
Date: 7 years ago
Size: 940 bytes


Class file image Download

 * Single page, multiple use form example. Shows use of a single form to
 * acquire multiple database records.
 * @author Thiemo Mättig (

// Include the class.
// Create an instance of the class.
$form = new Apeform();

// Add some form elements. Note the ampersands (get the values as references).
$name = &$form->text("Name");
// Do some basic error handling.
if (! $name) $form->error("Name missing");
$age = &$form->text("Age", "\tYears", 0, 2);
if (
$age < 1) $form->error("Age missing");
$form->submit("Insert Record");

if (
// Process the database query (dummy code in this example, of course).
echo "INSERT INTO table SET name = '$name', age = '$age'";
// Reset the form elements (that's the trick to empty the form).
$name = "";
$age = 0;

// Display the form.