Miscellaneous
  Home arrow Miscellaneous arrow Multi-page Forms with PHP
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Download TestComplete 
Forums Sitemap 
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MISCELLANEOUS

Multi-page Forms with PHP
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 9
    2002-11-12

    Table of Contents:
  • Multi-page Forms with PHP
  • Using the function
  • Examining the Function
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Multi-page Forms with PHP


    (Page 1 of 4 )

    This article will touch on two skills in the interface between PHP and HTML forms, specifically in working with hidden fields, and as a bonus, in passing arrays in an HTML form.

    By : Sam Fullman

    This article will touch on two skills in the interface between PHP and HTML forms, specifically in working with hidden fields, and as a bonus, in passing arrays in an HTML form.

    If you've been on the web at all, you've gone through multipart forms, where you fill out, let's say, section one, click submit, and fill in section two, etc.. This makes sense from dividing the forms into chunks, controlling the amount of information received, and also for verfication. If we want the user to set up an account with us, we might want to make sure that the username and password they select are unique before we have them fill out much else.

    At some point in your coding career, you're going to need to use hidden fields to hold values from a previous form. For example, if Form 1 had an input field as follows:

    <input type='text' name='username'>

    And you have globals turned on, Form 2 should carry this hidden field:

    <input type='hidden' name='username' value='<?php echo $username;?>'>

    This will "forward" the value of the text field to the hidden field on the second form. If you have globals turned OFF, you'll need to rewrite the second field slightly:

    <input type='hidden' name='username' value='<?php echo $_POST['username'];?>'>

    The concept is pretty simple; this way when the user submits Form 2, the values on form 1 go along with it. However, if you've got 5 forms with 15 questions each, form 2 will have 15 hidden fields, form 3 will have 30, form four will have 45, etc. That's a lot of hand coding, AND you'll have to change (5-n) fields if you change 1 question on Form n.

    I finally came to the point where I'd had enough, and this function I'm providing was the answer. The name of the function is field_forwarder(), and it's going to be a good friend on some of the complex projects I'm about to head up. In a nutshell, it takes all of the fields in a form collection, and outputs HTML hidden fields. Please click here for the code.

    More Miscellaneous Articles
    More By Codewalkers


       · Hi there,I checked this tutorial. what about passing variables to another HTML...
       · Please excuse me if I missed something.The tutorial says which code goes in page...
     

    MISCELLANEOUS ARTICLES

    - Firefox Plugins You`re Not Using (and Should...
    - Working with MP3 ID3 Tags in FTP Server Usin...
    - How Switching to Linux Can Make Your Computi...
    - Set Up Your Home Office on Linux: a Guide fo...
    - Putty File Transfer Commands in SSH Protocol
    - Setting Up Ubuntu for Your Home Office
    - Installing Mint Linux
    - Crucial Traits of Awk
    - Using PHP to Stream MP3 Files and Prevent Il...
    - 10 Must Have Firefox Improvements
    - All About OpenOffice 3.0
    - Shell Script Writing
    - Loops in the UNIX Shell
    - The Test in the UNIX Shell
    - Data Streams and the UNIX Shell





    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek