About usContact usSite help
Quick links
Search this site

CGI

Please see our Important Notice , we recommend that you read it before you proceed.

The common gateway interface (CGI) is a standard way for a Web server to pass a user's request to an application program and to receive data back to the user. When the user requests a Web page (i.e. by clicking on a hypertext link 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 submits it, 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 Hypertext Transfer Protocol (HTTP).

If you are creating a Web site and want a CGI application to take control, you specify the name of the application in the uniform resource locator (URL) that you code in an HTML file. This URL can be specified as part of the <FORM> tags if you. For example, you might code:

<FORM METHOD="POST" ACTION="http://username.demonweb.co.uk/myform.pl">

or even just

<FORM METHOD="POST" ACTION="myform.pl">

and the server at "username.demonweb.co.uk" would pass control to the CGI application called "myform.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. Also note that CGI or Perl is case sensitive.)

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 developer who writes the application program can make sure it gets used no matter which operating system the server uses (PC, Macintosh, UNIX, OS/390 etc). It's simply a basic way for information to be passed from the Web server 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 on the server before the page is displayed.

Here is some sample CGI (Perl) code.

CGI (Perl)

Useful Links


IMPORTANT NOTICE

The URLs referred to above are hosted by third parties. THUS shall not be responsible or liable for the content, materials or software provided by any third parties, including, without limitation, any error, omission or inaccuracy therein. THUS is unable to provide any support services in relation to any software downloaded from or referred to in the URLs referred to above. Demon is a brand of THUS plc.
Back to top


More Help





*