dkFlyer

CGI Primer

Common Gateway Interface (CGI) Programming is
the Method of Interacting Web Browser Clients
with Live and Queryable Information from the Web Server.

Instead of just having Normal 'Fixed', or 'Hard-Coded' HTML Documents,
CGI allows you to 'React' to the Needs of the Individual Client Browser,
and then Return Information based on these Needs.

CGI Programming can be done in almost any computer language.
But, the most popular languages for CGI Programming are:
Perl, the 'C-Family' of C / C++ / Java and the Microsoft-only standards of ASP / ActiveX.

Since Perl Coding Syntax is so much like the C-Family Coding Syntax,
you could actually make an argument that Perl is 'Part' of the C-Family.

CGI Programming begins with a Form, something like this:
All Tutorials are Intended to be Totally Harmless, Secure and Safe.
No Information is being retrieved from you or your personal computer.

HTML CGI Form Test

Name:

Address:

City:

State, Zip

Phone:

Fax:

EMail:

The Form is then SUBMITted to the CGI Program / Script for Processing,
which then Returns another Form, starting all over again.
(You can view this 'test.pl' Script here.)

By Combining CGI Programming with a Web Database,
you could run your Entire Website without Any Fixed HTML Documents!

CGI Programming can be Enhanced by using Browser Script Programs.
The most popular languages for Browser Script Programs:
JavaScript and the Microsoft-only standard of Visual Basic Script.
And, the new PerlScript is also now becomming popular.

JavaScript is 'Part' of the C-Family of C / C++ / Java.
Since PerlScript Coding Syntax is so much like the C-Family Coding Syntax,
you could actually make an argument that PerlScript is also 'Part' of the C-Family.

Browser Script Programming is usually used to Manipulate the Form
such as, verifying that Text Boxes are filled, etc
after you hit SUBMIT, but before the Form is actually SUBMITted to the Server.

View a JavaScript Validation here and a VBScript Validation here.

The common gateway interface (CGI) is a standard way for a Web server to pass a Web user's request to an application program and to receive data back to forward to the user. When the user requests a Web page (for example, by clicking on a highlighted word or entering a Web site address), the server sends back the requested page. However, when a user fills out a form on a Web page and sends it in, it usually needs to be processed by an application program. The Web server typically passes the form information to a small application program that processes the data and may send back a confirmation message. This method or convention for passing data back and forth between the server and the application is called the common gateway interface (CGI). It is part of the Web's HTTP protocol.
If you are creating a Web site and want a CGI application to get control, you specify the name of the application in the URL that you code in an HTML file. This URL can be specified as part of the FORMS tags if you are creating a form. For example, you might code:
<FORM METHOD=POST ACTION=http://www.eliteornamental.com/dkflyer/test.pl>
and the server at "dkflyer.com" would pass control to the CGI application called "test.pl" to record the entered data and return a confirmation message. (The ".pl" indicates a program written in Perl but other languages could have been used.)
The common gateway interface provides a consistent way for data to be passed from the user's request to the application program and back to the user. This means that the person who writes the application program can makes sure it gets used no matter which operating system the server uses (PC, Macintosh, Unix, OS/390, or others). It's simply a basic way for information to be passed from the Web server about your request to the application program and back again.
Because the interface is consistent, a programmer can write a CGI application in a number of different languages. The most popular languages for CGI applications are: C, C++, Java, and Perl.
An alternative to a CGI application is Microsoft's Active Server Page (ASP), in which a script embedded in a Web page is executed at the server before the page is sent.

What is My Preference for CGI Programming?

On an ISP (Internet Service Provider) where Resources are Limited,
I use Perl Programming with Minimal JavaScript where necessary.
Perl is a Relatively Easy and Simple Variation of the C-Family of Programming.
JavaScript provides the Greatest Flexibility for working with Most Browsers.

For a Full Service Web Server,
see the Editorial on Web Databases here.

Back to the Table of Contents


Author: Dennis Kennedy
Copyright © 1998 dkFlyer
If you have any questions, email me.

Hosted by www.Geocities.ws

1