PHP Classes
Icontem

File: example_multipage2.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_multipage2.php  
File: example_multipage2.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 a single form.
$form = new Apeform();

$page 1;

// Add the first form elements.
$element0 $form->text("First form, element 0");
if (empty(
$element0)) $form->error();
$form->addClass("page1");
$element1 $form->text("First form, element 1");
if (empty(
$element1)) $form->error();
$form->addClass("page1");
$submit1 $form->submit("Go to page 2");
$form->addClass("page1");

if (
$form->isValid()) $page++;

// Add some more form elements.
$element3 $form->text("Second form, element 3");
if (empty(
$element3)) $form->error();
$form->addClass("page2");
$submit2 $form->submit("Go to page 1|Submit both forms");
$form->addClass("page2");

if (
$form->isValid()) $page++;

if (
$submit1 == "Go to page 2")
{
    
$page 2;
    
$form->_isSubmitted false;
}
elseif (
$submit2 == "Go to page 1")
{
    
$page 1;
    
$form->_isSubmitted false;
}

echo 
'<style type="text/css">';
if (
$page != 1) echo '.page1{display:none;}';
if (
$page != 2) echo '.page2{display:none;}';
echo 
'</style>';

if (! 
$form->isValid())
{
    
// Display the 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