The Mechanics of CGI

The web server runs the CGI program and collects the output

The output is sent to the web browser. Usually it is formatted (by the CGI program) as a web page which is displayed just like any other.

N.B. : PHP will let you do the same sort of thing, but is not a CGI

For more : Last lectures in COMP1710, and COMP2720