Perl CGI  «Prev  Next»

Lesson 6State-Machine Guestbook
ObjectiveBuild a Guestbook CGI Program around the State-Machine Model

Build Guestbook CGI Program around the State-Machine Model

In the rest of this module, you will build the first of the two class projects, the guestbook program.
Pay close attention to how the program flows between HTTP connections. This will give you a practical example of how to build other programs using these tools.
The full source code for the program, inlcuding the images and the associated htmlp files, is available for download from the course Resources page. You may want to print a copy of the guestbook program to refer to during this lesson.
Overall structure: The overall structure of the program is very simple:
  1. Read the state information from the query string and make it available globally.
  2. Dispatch to the appropriate routine, depending on the current state.
  3. Process the state as appropriate.
  4. Determine the next state.
  5. Build the HTML page with all the necessary information for the next state and send it to the browser.

Now, let us examine the nitty-gritty details of the guestbook CGI program.
In the next lesson, we will see how the state-machine model makes it easy to implement all these states.