Normally clicking on a link in a web browser causes the web server to return a static .html page. No matter who clicks on this link or how many times they do it, the resulting returned web page is always the same. To change a static .html page the site's webmaster must edit the contents of the .html file. On the other hand, a CGI script allows a link or a button in a web page to run a program on the web server. This program can do any number of things from getting the current date and time to performing a complex lookup and update in a database. In either case, the results are not the same every time the link or button is pressed. The process occurs something like this: User clicks on a link in a web page (e.g. http://www.yourname.com/cgi-bin/test.cgi). The web server runs the program test.cgi. The test.cgi program does what it is programmed to do. The test.cgi program also builds a .html file in memory and sends it back to the user's browser. It is the last two steps which make CGI scripts so useful. The program can perform what ever operations it needs to and it can then generate a .html page based on the results of these operations. When the CGI script is used with a database such as MySQL, many things are possible. Generally, the page returned to the user's browser contains the results of the database search. Or, if the user had provided information through a form in the web page, the database records were updated.
- 13 Users Found This Useful
