CGI: What the Heck Is That?

Let's unlock a little bit of the mystery about something called CGI. If it helps any, CGI means Common Gateway Interface. This is a method which is used to exchange data between the server (the hardware and software that actually allows you to get to your web site) and a web client (your browser). CGI is actually a set of standards where a program or script (a series of commands) can send data back to the web server where it can be processed.

Typically, you use standard HTML tags to get data from a person, then pass that data to a CGI routine. The CGI routine then performs some action with the data.

Some of the more common uses of CGI include:

A CGI routine can be anything which understands the CGI standard.  A popular CGI language is called PERL, which is simple to understand and use (well, compared to other languages). PERL is a scripting language, which means each time a PERL routine is executed the web server must examine the PERL commands to determine what to do. In contrast, a compiled language such as C++ or Visual Basic can be directly executed, which is faster and more efficient. 

Okay, in a nutshell (and greatly simplified), here's how it works:

  1. You (the webmaster) specify a form tag which includes the name of the CGI routine.
  2. You create HTML tags which retrieves data from your visitors.
  3. Each of the input tags includes a variable name. The data which is retrieved from the visitor (or directly set if the tag includes the "hidden" qualifier) is placed in the variable name.
  4. When the visitor presses the "submit" button, the CGI routine which was specified in the form tag is executed. At this time, the CGI routine "takes control", meaning the browser essentially is waiting for it to complete.
  5. This CGI routine can get data from variable names. It retrieves the data and does whatever action is required.
  6. When the CGI routine finishes, it returns control back to the web client (the browser).

Some important things to remember about CGI routines:

I hope this short introduction to CGI has cleared up some of the mystery.


Themestream Comments

VERY useful information. Thanks! - Amanda Wilkes Roa

Internet Tips Contents
404 Errors Advertising Autoresponse Awardmaster Basics Browsers Careers Chatting Disasters Domains Email Emoticons Ezines Free Stuff Fun Stuff FTP Graphics Homepages HTML Reference HTML Tutorial Interactive Legal Links Msg Boards Microsoft Money Multimedia Networks Newsgroups Newsletter Products RFC's Ringmaster Searches Security Sticky Sites Surfing TANSTAAFL Telnet Viral Webmaster Your System