An Example of Form Processing

Now let’s look at an example that demonstrates exactly how form processing works. This example consists of a simple application that displays a form, accepts the submitted form, validates the content, and displays the information (with or without an error message) back to the user.

The script itself is organized in components. The script begins with a pointer to the Perl executable. It follows by importing the CGI.pm module and creating a new query object to import the form parameters into the Perl namespace:

#!C:/perl/bin/perl.exe 

use CGI; 
$query = new CGI; 
					

The Main Script Logic

The body of the script contains the logic that determines whether to display the form for the first time, display the form with an ...

Get Sams Teach Yourself CGI in 24 Hours, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.