CGI stands for Common Gateway Interface, which is a standard for external gateway programs to interface with information servers such as HTTP servers. CGI is not a program or a programming language. It is a collection of protocols (or rules) that allow Web clients to execute programs on a Web server and receive their output (if any).
Usually, the most common way for CGI to work is that the Web client (users) enters input data (if needed, some CGI programs do not need any input, such as example2 mentioned earlier) , which are transferred to the server based on some protocols. The server receives the input, then passes the input to the CGI program. Then the CGI program is executed (fore example, by either sending mail to somebody via Formmail, or returning the search result back to the users if it is a search program...).
The conceptual working of a form-based CGI query is illustrated in Figure 1.
Figure 1.
Now let's reference Figure 1. Take the above "Hello, somebody" CGI program as an example to see the exact steps to run a form-based CGI program:
When you click Run
Hello somebody example the request is sent to the server.
This is what we received: