Despite what some people think, CGI is not a programming language. It is simply a method or protocol (a very old one) for interfacing external applications with servers. The NCSA describes CGI as follows:
A plain HTML document that the Web daemon retrieves is static, which means it exists in a constant state: a text file that doesn't change. A CGI program, on the other hand, is executed in real-time, so that it can output dynamic information.
For example, let's say that you wanted to "hook up" your Unix database to the World Wide Web, to allow people from all over the world to query it. Basically, you need to create a CGI program that the Web daemon will execute to transmit information to the database engine, and receive the results back again and display them to the client. This is an example of a gateway, and this is where CGI, currently version 1.1, got its origins.
A CGI application can be written in almost any programming language but most commonly Perl is used. Once the program is written it needs to be put in a special folder where external programs, like your web browser, can access it. It will carry out its action, like getting information from a database, and then return information back to your browser.
CGI is supported on almost any platform, Windows or Linux variants. CGI can be used for managing email, connecting to other web sites or servers, processing form information, storing information in a database, creating cookies in a web browser, and just about anything else.
A CGI program can be requested in a web browser using either the GET method or the POST method or something else. Most CGI programs will only work if you put them in a special directory called a cgi-bin in the root of your web site. You can then access the application like this:
If you are interested to learn about CGI we recommend the introduction given by the National Center for Supercomputing Applications at the University of Illinois. Sitepoint also offers some great CGI & Perl Tutorials. We also recommend that you learn about CGI using a book from the library or one of the following:
Keep in mind that most modern web programming languages don't use CGI and can do many of the same things more easily. Unless you know that you need to use CGI, we recommend you look into other programming languages, like PHP.