Hello and welcome to the Webmasters Forums!. This is the best place to get webmasters resources for free. Get $2 for free today, read more - Make your payment today. Download premium and professional templates for free. Get free web hosting without ads, read more. You can get lot more by simply join with this forum. To gain full access to the forums you must sign up for a free account.
Posts: 995
Group: Forum Team
Joined: Sep 2006
Status: Online
Make money from now. You can make money just for posting on this forum. Every discussions on this community gives you more money. $2 minimum payout. So get your payment today, SignIn with this forum.
Though some CGI programs accept no input data, most CGI applications do need to interactively communicate with the user - they need to receive information (or a query) from the users. This is why CGI is so important. CGI programs receive this information from CGI Environment Variables.
Usually, a CGI program receives two types of the information from the browser:
1. Information about the browser (its type, what it can view, the remote host name, and so on), the server (its name and version, the port it's running on, and so on), and the CGI program itself (the program name and where it's located). The server provides all of this information to the CGI program through environment variables.
2. Information entered by the user. This information, after first being encoded by the browser, is sent either through an environment variable (the GET method) or through the standard input (stdin- the POST method).
Here are the descriptions of some of the important CGI environment variables:
* QUERY_STRING
QUERY_STRING contains the input to a CGI application that is invoked with the GET method. The input string is URL-encoded (spaces replaced by plus signs, several characters escaped). Each piece of data being sent to the CGI application is sent in "key=value" form. If the POST method is used, QUERY_STRING will be empty.
* CONTENT_TYPE
CONTENT_TYPE gives the MIME types of data sent to a CGI application that is invoked using the POST method. When the CGI application is invoked using the GET method, the CONTENT_TYPE enviornment variable is blank. A typical value for the CONTENT_TYPE environment variable is application/x-www-form-urlencoded.
* CONTENT_LENGTH
CONTENT_LENGTH gives the length in bytes of data sent to a CGI application that is invoked using the POST method. When the CGI application is invoked using the GET method, the COPNTENT_LENGTH enviornment variable is blank.
* PATH_INFO
PATH_INFO gives extra path information as it was passed to the server in the query URL.
* REMOTE_ADDR
REMOTE_ADDR gives the IP address of the client that made the request.
* REMOTE_HOST
REMOTE_HOST gives the name of the remote computer that made the request.
* REQUEST_METHOD
REQUEST_METHOD gives the name of the method used to invoke the CGI application. Valid values are GET and POST.
* SCRIPT_NAME
SCRIPT_NAME gives the name of the script that was invoked, for instance, /cgi-bin/hello.cgi.
* SERVER_PORT
SERVER_PORT gives the TCP port number on which the server that invoked the CGI application is operating, for instance, 80 (the default HTTP port number).
* SERVER_PROTOCOL
SERVER_PROTOCOL gives the name of the protocol that server is using and the version of the protocol. For instance, HTTP/1.0.
* SERVER_NAME
SERVER_NAME is the domain name of the computer that is running the server software, for instance, http://www.cba.uh.edu