Because CGI is a standard of communication between the web server and CGI script, it
has some variables which it uses to allow the two to communicate to each other, to
transfer information. These variables are known as environment variables. They contain
various pieces of information, from the type of browser your visitor is using to the place
from which he or she is viewing your page. Below is a short list of environment variables
and descriptions to show you what kind of information you will get from your visitor aside from the form. It
really takes some programming experience to know how to use these, but it takes only the
imagination to conceive what can be done with them.
- Tells the type of authentication used if the web server supports it and the script is protected. An example of authentication may be a something like a password.
- When your form method is "post," the data in the form is sent in one long string or characters. The CONTENT-LENGTH tells how long the string is in bytes (characters). An example of CONTENT-LENGTH: 256 bytes
- You can send many kinds of data to a script. This variable tells what kind of data it is from a list of MIME types. A sample of CONTENT-TYPE: x-www-form-urlencoded (tells the script that this data came from a WWW form...)
- Tells the script what version of the CGI specification is being used. As with anything in the computer world, CGI is being updated and every change makes a new version; the higher the number, the newer the version. An example of GATEWAY_INTERFACE
- Gives any information that may be included in a URL in addition to the name of the script, such as extra options.
- Contains information on where the script resides; it lists the directories, the script name, and any other information
- This contains the information that follows the name of a script. It often contains information that the script can use to send you where you want to go, like a search engine. If you search for a topic in a search engine, like Infoseek, it will send you
to an index of pages. In the location box, after the URL and ?, you will sometimes see some words separated with +s and other characters. This is the query string and this is what is contained in QUERY_STRING.
- Contains the IP address of a visitor who is using a script. An example of REMOTE_ADDR: 246.74.105.3
- Contains the name of the computer of a visitor who is using a script. An example of REMOTE_HOST: Excelsior.
- Tells a script the name of the person using it. An example of REMOTE_USER: nhiemann
- Contains the immediate location of a script from the cgi-bin directory. An example of SCRIPT_NAME: /cgi-bin/myscript.cgi
- Gives the name or IP address of the computer on which the web server is running.
- Gives the port number on which the web server is waiting for requests. An example of SERVER_PORT: 80.
- Contains information on whatever protocol and its version number that the Web server is using. An example of SERVER_PROTOCOL: HTTP/2.0.
- Gives the name and version number of the Web server that called the script. An example of SERVER_SOFTWARE: APACHE/1.2b4
- Contains information on the types of information the visitor's web browser can display, often it is one or more of the MIME types. An example of HTTP_ACCEPT: image/gif,image/jpeg
- Tells the script from what form in what page the data is coming. An example of HTTP_REFERER: http://www.ourpage.com/comments.html
- Tells the script what browser and version of that browser your visitor is using. An example of HTTP_USER_AGENT: Mozilla/2.0(Windows;32bit)