CGI is a delivery mechanism and data processing, a process that takes place from which the user is presented with the form data entry until you get the result page to process the data:
1. The user is presented through your browser an HTML page containing a form, encoded by the <FORM> and </ FORM>. Once the user has filled the form fields, click the submit button, which invokes the CGI program on the server.
2. The form data is sent to the server using either the POST method or the GET method, the advantages / disadvantages for safety shall see shortly.
3. The data arrives to the server through the Internet, where the CGI invoked application processes them.
4. A suitably processed once, the CGI program must execute an action or generate a response, usually in the form of a page in HTML format, which will be sent back to the browser.
5. The necessary HTTP headers are added and sent back via the Internet the HTML file with the response to appropriately submitted form data.
6. The Web browser receives the HTML file and displays it on screen. It is common that the page contains some information related to the processing result of the data, along with a link back to the form page, in step 1.
Importantly, it is not necessary the presence of a form to be invoked from the browser to the server CGI. Often, simply tap on a link to call the CGI and it is also possible to call directly from the URL window, entering the full URL of the CGI program.