Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
Python, Lua, Tcl, C and C++ training - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Java, Ruby, MySQL and Linux / Tomcat systems
Application design in PHP - multiple step processes

StatusWhen you're putting together a multiple step process in PHP (and that could be anything from a forum to an ordering system), you should bare in mind that each of the program elements will be the 'intermediate' step that takes you from one display to the next ... and that you can't be sure when page "X" has been completed that the next page to be presented really WILL be page "Y" - after all, if the user has failed to enter his password correctly on page "X" you'll want to redisplay it ...

Flow... so here, in principle, is how your code should look. Your application will pick up form data and any existing information from the user's session, then "finish" processing from those inputs. Part of that finishing process will be making the decision as to what page to move onto next, so after finishing from page "X" the code will prepare for page "Y", or page "X" again perhaps. Upon completion of those preparations, the (newly updated) session is saved away, and a template for the new page completed.

4 layer modelRather than store all the code associated with such a multipage application in one file / logical area, we'll usually split it up. The top level code goes into one file, the "business logic" - code to do the actual application work - into another. A third file contains the "web helpers" - routines which handle the forms, sticky fields, web principles, etc. And a fourth file contains a template - what the web page presented will actually look like.

By splitting the code in this way, it becomes easier to maintain as it's in sensible sized chunks. It also allows for elements to be reused in other areas of the web site / application - for example, a template might be shared right across a site, web helpers across many sites, and the business logic may be used offline as well as on the web. Finally, the division principle allows each section to be independently looked after by experts in that section - you need staff who are masters at each individual trade rather than staff who can dabble a bit in all areas.

If you have heard about MVC ("Model View Controller") parts of what I have written may sound very familiar indeed ... and that is no accident!

We have a sample 'shell' of an application that goes through a multistep process using these principle and you can run it here. Source code is here (top level), here (business logic), here (web helpers) and here (template).

This subject is taught briefly on our learning to program in PHP and PHP programming courses, and much more fully covered during our PHP techniques workshop
(written 2009-05-11)

Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
H302 - PHP - MVC, 4 layer model and templating
  [4314] PHP training - refreshed modern course, backed up by years of practical experience - (2014-11-16)
  [4114] Teaching CodeIgniter - MVC and PHP - (2013-06-12)
  [4066] MVC and Frameworks - a lesson from first principles in PHP - (2013-04-19)
  [3956] Zend / layout of MVC and other files in an example application (PHP) - (2012-12-16)
  [3539] Separating program and artwork in PHP - easier maintainance, and better for the user - (2011-12-05)
  [3454] Your PHP website - how to factor and refactor to reduce growing pains - (2011-09-24)
  [2221] Adding a newsfeed for your users to a multipage PHP application - (2009-06-06)
  [2199] Improving the structure of your early PHP programs - (2009-05-25)
  [1766] Diagrams to show you how - Tomcat, Java, PHP - (2008-08-22)
  [1716] Larger applications in PHP - (2008-07-22)
  [1634] Kiss and Book - (2008-05-07)

Back to
Basic OO principles
Previous and next
Horse's mouth home
Forward to
Melksham in pictures
Some other Articles
Melksham Candidates for Wiltshire Unitary Election
Preventing forum spam - checks at sign up
Balloon Journey in Wiltshire
Melksham in pictures
Application design in PHP - multiple step processes
Basic OO principles
PHP4 v PHP5 - Object Model Difference
Cleaning up redundant objects
Designing a heirarcy of classes - getting inheritance right
When should I use OO techniques?
4754 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 at 50 posts per page

This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2017: 404 The Spa • Melksham, Wiltshire • United Kingdom • SN12 6QL
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/2174_App ... esses.html • PAGE BUILT: Sat May 27 16:49:10 2017 • BUILD SYSTEM: WomanWithCat