PHP
  Home arrow PHP arrow Page 3 - Making PHP Forms Object-Oriented
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
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? 
PHP

Making PHP Forms Object-Oriented
By: Yuri Makassiouk
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 29
    2003-01-23

    Table of Contents:
  • Making PHP Forms Object-Oriented
  • Analysis
  • Executing Environment
  • Implementing the FormProcessor Class
  • Inputs - Brief Introduction
  • Example of a Form
  • 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


    Making PHP Forms Object-Oriented - Executing Environment


    (Page 3 of 7 )

    Before we go deeper into details, there's one important thing to talk about. That is, how do we organize forms into a branching sequence (I hope, nobody minds me using the word 'wizard' here)?

    Here's what I suggest. You may think of it as of some kind of a 'runner' that manipulates instances of classes derived from FormProcessor. This environment knows which form (script in a separate file) should be loaded first. It then includes the script containing a form (FormProcessor's descendant).

    This form decides whether it is still displaying itself or just finishing processing of data submitted to it. After storing correct data it reports to the runner: “hey, I'm finished now - look, this is who should be next”.

    Based on this information, the runner can load the next form, according to the decision made in the current one. The next form, when included, will sense that it is just loaded for the first time. It will notify the environment (runner) about that and the chain will stall at this point; Of course, waiting for the next form to be submitted.

    Before something else distracts us, let's see what I meant here in the code:

    <?php

      /**
      * A 'runner' - environment for managing form wizards
      *
      * @author Yuri Makassiouk <racer@bfpg.ru>
      */
      //include('constants.php3');
      //this is the directory where forms (wizard's screens) reside:
      $wizardRoot = '';
      if (!isset($wizardPage))
        //initialize sequence. (This value should normally not be hard-coded)
        $wizardPage = 'reg_form01.php';
      clearstatcache();

      while ($wizardPage) {
        $page = ($wizardRoot . $wizardPage);
        //echo ' ' . $wizardPage . ' ';  // - uncomment this to monitor what's going on
        $wizardPage = ''; // this will stall the wizard
        if (file_exists($page)) {
          // the included file may either set the global variable $wizardPage
          // and that will continue the loop instantly
          // or it may have the pair 'wizardPage=...' get submitted
          // with a form the file contains.
          include($page);  
        }
        else {
          echo "<br><b>Form wizard:</b> cannot find '$page', aborting wizard";
          // this break isn't really necessary - no included file - nobody to
          // set $wizardPage being != ''. But just in case, you know =)
          break;
        }
      }

    ?>


    Now, if you put the code above in a separate file, you may then include that file in your nicely formatted page. This page will be displaying your wizard's screens.

    More PHP Articles
    More By Yuri Makassiouk


     

    PHP ARTICLES

    - Making Usage Statistics in PHP
    - Installing PHP under Windows: Further Config...
    - File Version Management in PHP
    - Statistical View of Data in a Clustered Bar ...
    - Creating a Multi-File Upload Script in PHP
    - Executing Microsoft SQL Server Stored Proced...
    - Code 10x More Efficiently Using Data Access ...
    - A Few Tips for Speeding Up PHP Code
    - The Modular Web Page
    - Quick E-Commerce with PHP and PayPal
    - Regression Testing With JMeter
    - Building an Iterator with PHP
    - PHP Frontend to ImageMagick
    - Using PEAR's mimeDecode Module
    - Incoming Mail and PHP






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
    Stay green...Green IT