Miscellaneous
  Home arrow Miscellaneous arrow Page 3 - 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  
Forums Sitemap 
Dedicated Servers  
Download TestComplete 
JMSL Numerical Library 
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
     
     
    ADVERTISEMENT


    Multi-page Forms with PHP - Examining the Function


    (Page 3 of 4 )

    Usually I'd give a very detailed explanation of how a function works, but this one was very complex conceptually, and so I'll just hit some high points.

    First of all, this is a recursive function, which means that under certain conditions it calls itself. Recursive functions are a good way to get something done fast, and also a safe way as I believe functions are set up in their own separate memory space. The flip side of designing recursive functions is that you must be careful to declare globals as you need them. For example, if you a function called some_kind_of_loop() which declares variables, you must either declare them as global or pass them to the function the next layer down, or they won't be available at that level.

    Secondly, for those of you who may not know, the following two array elements are different:

    <?php
    $info
    ['interests'][01] = 'hockey';
    $info['interests']["01"] = 'figure skating';
    ?>

    Try echoing these both and you'll see what I mean. In the first case the 01 is taken as a number, and the second it's taken as a string (even though it's a numeric value and you can still add and operate on it math-wise). In my function, quotes are NOT added if the key (index) is purely numeric. This may cause a bug if you're using some value like 01, so you can get in and change that in the code, see lines 54-58 to change this.

    Finally, remember that when you put a value in a form, it may contain a double quote, and if you have magic runtime quotes turned on, values with a single quote will have a slash added. For example, this line of string,

    I didn't "do it," she said.

    will show like this:

    I didn\'t

    That's because single quotes will have a slash added on posting, and the double quote is interpreted as the end of the value.

    To correct this, my function takes the following string and filters it through two PHP functions:

    <?php
    $value 
    'I didn\'t "do it," she said';
    htmlentities(stripslashes($value));
    ?>

    This changes the string to:

    I didn't &amp;quot;do it,&amp;quot; she said

    Which will post correctly.

    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 2 hosted by Hostway