Prev Up Next
Go backward to 4.4 CGI Introduction to Perl Topic #2
Go up to 4 Major Topics
Go forward to 4.6 Cookies

4.5 Form Processing

This topic is to introduce HTML forms. This is where the WWW gets a bit more interesting. The client can finally provide some real data to the server.

The data from the user can be information about the user, information about something wanted, or purchase information. The possibilities are endless.

There are two primary ways for the CGI program to get the data, "POST" & "GET". POST sends the input through the the standard input to the CGI program while GET uses the environment variable "QUERY_STRING". You can determine the type of request by looking at the environment variable "REQUEST_METHOD".

The details in handling the the character translations and different form methods needs little attention. Use someone else's code to do it. Look at the file common.pl for some ideas, or just use it. You may want to revise your last lab so that it can handle forms using ether method.

4.5.1 Preparation

  1. Read Chapter 4 of CGI Programming by Gundavaram On the web at O'Reilly. Pages 51-85.
  2. Create a form, and point it at your environment program. Look at the environment created by the HTTPD as provided to your program when presented with a form.
  3. If you choose, modify the program to look at the standard input STDIN if the request method is "POST".

4.5.2 Group Task

If you have a project in mind with about the same complexity using forms please talk to me before starting this one. It never hurts to do something that is actually useful to someone.

4.5.3 Report

Turn in your group's report (only one copy please) marked as follows:
  1. A printout of your Perl CGI program.
  2. A printout of your file (not too much data, just enough to show your format.
  3. A printout of your processed data report from a web browser.

Instructor: ltaber@pima.edu** Red's Home page** The Pima College Site

Prev Up Next