If you have been browsing the web for a long time, it is certain that you will come across the term CGI, which means Common Gateway Interface. CGI refers to a communication protocol that enables a web server to communicate with other applications. For example, a CGI application sometimes called a script is often used to allow web users to enter a database or get information from forms people have filled out. CGI can also be used to create agents that do things like check a website for broken links.
It is essentially a standard way in CGI where the web is interactive with external sources. External sources are usually a database. You have probably worked with CGI scripts many times without knowing what happened. For example, if you filled out a form on a web page to register to use a site and you received an e-mail with a password to use in return, you probably ran a CGI script. In this case, the CGI script probably took your form and performed various operations on it (including putting the information in a database, automatically creating a password and sending the e-mail to you).
CGI and CGI applications are often confused. CGI applications retrieve information from the server and retrieve the information via CGI. CGI applications are usually written in a programming language called PERL, although it can also be written with C, C ++, pascal, AppleScript, and others. CGI itself is a standardized environment that provides communication between a CGI application and an HTTP server. It is a "door-to-door" where a CGI application from which the web server sends the requests collects and classifies the information sent back.
CGI performs many tasks, in the example where information on a web page designed to accept user data is provided. First of all, a special information (a name or an e-mail address) is presented and processed by the server. Then the information is forwarded to a CGI application defined by the server as "submit". It is activated by the customer. Finally, a CGI application sends the information of the form to another computer program, stores it in a file, or even creates a custom HTML d0cument in response to the user's request. This is defined as an interactive form.
Accompanying this section, we will check a CGI program that allows a motion picture database search.
The person calling the website does not need to know the programming to access the CGI programs. Instead, a programmer writes the CGI program. Many different languages can be used for CGI (such as C or C ++, FORTRAN, Visual basic and AppleScript). An application written in a program language such as C must first pass through a program called compiler before it runs. Compiler translates the application into a language CGI can understand. Other languages, called scripting languages, do not have to go through the compiler first. Compared to compiled programs, CGI scripts are used more often because they are easier to debug, modify and maintain. The most popular language used for the software of CGI scripts is PERL.
After the program is written and collected or scripted, the program is placed in a special directory (such as / cgi-bin) on the web server where all CGI programs are located and maintained. The person who is responsible for the web server determines which directories will be used for storing and running CGI programs.
After the CGI program is sent to a special directory, a link will be established in a URL on a Web page.
If the CGI program allows you to search a database when you visit the website and click on the URL, for example, it will submit a form in HTML format. Following this, you will fill in a form detailing what you are looking for. If you complete this form and click on send, the information on the form will be sent to the CGI program.
The CGI program contacts a database and requests the information the user is looking for. The database also sends the requested information to the CGI program. Information can be in various formats (such as text, graphic, sound file, image file and URL).