CGI Environment Variables & Forms

Here's a brief description of the way CGI works. A URL designating a CGI program file, as opposed to an HTML text file, is received by the ISP's server. It sets several environment variables and then invokes the program. The program reads the environment variables and picks up any transmited data (via one of two methods). It processes the data and returns, HTML text to the server, which forwards it back to the original sender.

There are two methods of sending data from an original sender to a CGI program, they're called GET and POST. The difference is that GET appends data fields to the end of the URL and POST transmits the data as a separate step. You've probably seen GET URLs, they look something like this: http://www.kentfeiler.com/cgi-bin/cgiprog?keyword=value?keyword=value. The URL for a POST CGI method would be the same except missing the parameter data, i.e. http://www.kentfeiler.com/cgi-bin/cgiprog. There are two disadvantages to GET, (1) the command line is visible to whoever might want to intercept it, and (2) it has a size limit. As a result, POST is the most used method.

Following are two forms, one GET and one POST. Enter some data in the fields provided select a Stooge, and then click one of the submit buttons (WHACK, MASH, POUND, or SMACK). You'll get back a list of the environment variables that are related to the two methods. For the GET method, REQUEST_METHOD will be GET and QUERY_STRING will contain the data you submitted. For the POST method, REQUEST_METHOD will be POST, QUERY_STRING is null, and CONTENT_LENGTH contains the data length.


GET Method Form

The name of the following field is, "Txt". Enter some stuff here and see how it appears in QUERY_STRING. Particularly try entering +, =, &, and %.



These radio buttons are all named, "Stooge" Pick your favorite.
Larry Moe Curley


These submit buttons are all named, "Action". Use any one of these to submit your request.


POST Method Form

The name of the following field is, "Txt".



These radio buttons are all named, "Stooge". Pick your favorite.
Larry Moe Curley


These submit buttons are all named, "Action". Use any one of these to submit your request.


Back to the Webmaster Page