Getting Started with CGI
Make your Web site more
meaningful with online quizzes, database interfaces, and more! This overview
will introduce basic CGI concepts, programming languages, and tools to help
you put your Web sites and learners to work.
What is CGI?
The Common Gateway Interface
(CGI) is a standard for interfacing Web servers with applications. A plain HTML
document on the Web is static -- a text file that doesn't change. A CGI program,
on the other hand, can output dynamic information, making a Web page more useful
for learners. In other words, a CGI program does something with the stuff users
type into forms.
You can use CGI's for searching,
gathering or sharing database information, online quizzes, generating Web pages,
and more. How about online portfolios, guestbooks, or district data collection?
Here are some examples:
- Blue
Web'n uses a Perl CGI to search a simple text database and an e-mail CGI
to automate listserv subscription.
- The Eyes
on Art Quiz uses a Perl CGI to check responses and spit out feedback.
- Filamentality
prompts users for input and creates a Web page based on that input.
How Does CGI work?
CGI programs run on the server
and are thus less prone to client idiosyncrasies that make JavaScript development
a challenge.
Here's the usual chain
of events:
CGI Languages and Tools
Some popular CGI programming
languages include AppleScript, C/C++, Perl, and Visual Basic. Of these, Perl is
probably the most widely used. Perl is free, powerful, portable (Macintosh, Windows,
and UNIX), readily available, and fairly easy to learn.
You can use Perl to create
database interaction CGI's, but many people appreciate the ease of higher level
tools such as Everyware's Tango and Web
FM. These tools will help you build Web page forms that let remote users
search or add to your database.
Getting Started with CGI
To create your own CGI's, you'll
need access to a Web server. It's helpful to have solid understanding of HTML
and some exposure to HTML FORM tags. It's nice to have cooperation from a system
administrator to help you install software and troubleshoot.
Strategy for Learning Perl
- Download Perl. Tom
Christiansen's Perl Language Home Page links to software and resources.
- Work through the Introduction
of Learning Perl
to get familiar with Perl syntax. This book doesn't get into CGI development,
but it's an excellent syntax introduction and reference.
- Download cgi-lib.pl.
This Perl cgi handles form input and output. See perlWWW
for other Perl programs and libraries related to the World Wide Web.
- Skim Common
Gateway Interface, an introduction to CGI. In particular, review Decoding
FORMs with CGI and skim the FORM
tags reference.
- You'll probably want
to use a Perl CGI to get data from a form, do something with the data, and
provide output. Try this simple Perl input-output template
to get started. You'll need cgi-lib.pl and access to a Web server with Perl
installed.
Resources