PHP Classes
Icontem

File: example_multipage.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_multipage.php  
File: example_multipage.php
Role: Example script
Content type: text/plain
Description: How to split a form into multiple pages
Class: TM::Apeform
A very abstract web form builder and processor
 

Contents

Class file image Download
<?php

/**
 * Multiple page form example. Shows use of a big multiple page form to
 * acquire a large ammount of data.
 *
 * @author Thiemo Mättig (http://maettig.com/)
 */

require_once("Apeform.class.php");

// Create the first form.
$form = new Apeform();
// Add the first three form elements.
$element0 $form->text("First form, element 0");
$element1 $form->text("First form, element 1");
$form->submit("Go to second form");

if (! 
$form->isValid())
{
    
// Display the first form.
    
$form->display();
}
else
{
    
// Create the second form.
    
$form = new Apeform();
    
// Create hidden elements for any element that comes from the first form.
    // Although they look like dummy elements, they are required components.
    
$form->hidden(); // element0
    
$form->hidden(); // element1
    
$form->hidden(); // element2
    // Reset the submission state of the form (private object property).
    
$form->_isSubmitted false;
    
// Add some more form elements.
    
$element3 $form->text("Second form, element 3");
    
$form->submit("Submit both forms");

    if (! 
$form->isValid())
    {
        
// Display the second form.
        
$form->display();
    }
    else
    {
        
// Process the collected form data.
        
echo "INSERT INTO `table` SET `element0` = '$element0'";
        echo 
", `element1` = '$element1', `element3` = '$element3'";
    }
}

?>

 
  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