Miscellaneous
  Home arrow Miscellaneous arrow Multi-page Forms with PHP
IBM developerWorks
Try It Free
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  
Forums Sitemap 
Dedicated Servers  
Download TestComplete 
IBM® developerWorks
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 / 6
    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
     
    Try It Free
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    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

    - Stopping CSRF Attacks in Your PHP Applicatio...
    - Quick and Dirty AJAX Tutorial
    - Flickr Puzzle Mashup
    - The PAVISE of Security
    - Creating a CAPTCHA with PHP
    - Sending SMS Thru HTTP
    - The Postal Fix - Part 2
    - Adding Mail with Exim
    - The Postal Fix - Part 1
    - Create Your Own Custom API
    - Adding Drop Shadows with PHP
    - Writing a Basic Authentication System in PHP
    - Overlapping Images with GD
    - Using Sockets in PHP
    - Dynamic CSS with PHP





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway