PHP Classes
Icontem

File: example_multiuse.php


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend! ReTweet ReTweet Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Thiemo Mättig  >  TM::Apeform  >  example_multiuse.php  
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
 

Contents

Class file image Download
<?php

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

// Include the class.
require_once("Apeform.class.php");
// 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"02);
if (
$age 1$form->error("Age missing");
$form->submit("Insert Record");

if (
$form->isValid())
{
    
// 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.
$form->display();

?>

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2009 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products