ARCHIVED: What is CGI?

This content has been archived, and is no longer maintained by Indiana University. Information here may no longer be accurate, and links may no longer be available or reliable.

The Common Gateway Interface (CGI) is a method of allowing a hyperlink to refer to a program rather than a static web page. The easiest way to understand how a CGI works is by contrast with an ordinary web page.

How does CGI work?

When you use a browser to link to a URL, the browser requests that the host named in the URL send the data specified by the rest of the URL. This is normally just the contents of the file or directory specified by the URL, encoded with the appropriate MIME type.

However, if the URL points to a CGI, the computer on the far end runs the program, and sends its output to the client as though the output were the contents of an HTML file. Depending on the URL, you might not be able to tell that a CGI ever ran.

CGIs are often used for processing submissions from HTML forms (collections of fill-in fields, checkboxes, buttons, etc.). They can also generate variable or customized content for a web page, ranging from visitor counters to data based upon information supplied by the client browser.

How can I write a CGI program?

You can write a CGI program in any programming language supported on the server computer. You can find many tutorials on the web to help you write a CGI. The following two are a good start:

  http://www.lies.com/begperl/
  http://wdvl.com/Authoring/CGI/

In addition, a number of excellent packages have been written that make it easier to program CGIs in Perl or C. To browse a huge collection of resources about CGI, HTML, forms, and all aspects of the web and the Internet, visit the University of Geneva's TECFA Toolbox page at:

  http://tecfa.unige.ch/guides/toolbox.html

Note: CGI (computer-generated imagery) also refers to special effects graphics (in film, television, etc.) created with a computer.

This is document bacg in the Knowledge Base.
Last modified on 2023-09-22 16:59:20.