--- Environment Variables ---
[ Previous Section | Home | Index | Test Your HTML | Related links | Next Section ]



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.



AUTH-TYPE

- 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.


CONTENT-LENGTH

- 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


CONTENT-TYPE

- 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...)


GATEWAY_INTERFACE

- 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 : 1.1


PATH_INFO

- Gives any information that may be included in a URL in addition to the name of the script, such as extra options.


PATH_TRANSLATED

- Contains information on where the script resides; it lists the directories, the script name, and any other information


QUERY_STRING

- 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.


REMOTE_ADDR

- Contains the IP address of a visitor who is using a script. An example of REMOTE_ADDR: 246.74.105.3


REMOTE_HOST

- Contains the name of the computer of a visitor who is using a script. An example of REMOTE_HOST: Excelsior.


REMOTE_USER

- Tells a script the name of the person using it. An example of REMOTE_USER: nhiemann


SCRIPT_NAME

- Contains the immediate location of a script from the cgi-bin directory. An example of SCRIPT_NAME: /cgi-bin/myscript.cgi


SERVER_NAME

- Gives the name or IP address of the computer on which the web server is running.


SERVER_PORT

- Gives the port number on which the web server is waiting for requests. An example of SERVER_PORT: 80.


SERVER_PROTOCOL

- Contains information on whatever protocol and its version number that the Web server is using. An example of SERVER_PROTOCOL: HTTP/2.0.


SERVER_SOFTWARE

- Gives the name and version number of the Web server that called the script. An example of SERVER_SOFTWARE: APACHE/1.2b4


HTTP_ACCEPT

- 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


HTTP_REFERER

- Tells the script from what form in what page the data is coming. An example of HTTP_REFERER: http://www.ourpage.com/comments.html


HTTP_USER_AGENT

- 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)



[ Previous Section | Home | Index | Test Your HTML | Related links | Next Section ]