So, what do we have so far?
- First you write an HTML page with a FORM in
- Some user retrieves your HTML page using a web
- The web browser interprets the HTML and
presents the Form to the user as a set of input widgets.
- The user inputs some data into the widgets and
then clicks on a submit button
- The browser then goes through each of the
input widgets and collects the information that the user has input
and creates the body of the HTTP call it is going to send to the
server referenced in the FORM ACTION attribute.
- Then the browser contacts the server using
the method defined by the FORM tag's METHOD attribute and hands off
So what does the server do with the
Typically, the server will hand the request
off to some CGI script that has been specified in the ACTION
attribute in the FORM tag that made the request
So the server must execute the CGI script
and feed it the data received from the web browser.
To do so, the server creates an associative
array that will be used to hold all of the data needed by the
array is called %ENV (You'll learn more about accessing and
building associative arrays tomorrow).
A good deal of this information will be gleaned from the browser
itself and a lot of it is really obscure junk that you will
rarely use. However, for your reference, the following table
outlines the Environment variables prepared by the server
||Specifies the authentication method used
to validate the user. This will only be set if the server is set to
||The number of bytes in the message body of the HTTP request.
This is used by POST method request.
||The media type of the incoming data.
||Specifies the protocol name and revision being used by
the server to communicate with the script.
||Holds a comma delimited list of MIME types that the
client will accept
||Specifies the address of the web page that posted
||The name and version of the web browser used to make
||Extra path information specified in the URL that called
||The server's real file system path to the
||The URL-encoded data in a GET request
||Specifies the IP address of the client's
||Specifies the client's domain name.
||Specifies the client machine's username if
||Specifies the name used to authenticate the user if the
user was authenticated using server-based authentication
||Specifies if the request was GET or POST
||Specifies the virtual name of the script. (The directory
||The server's domain name
||The port that the web server is running on
||The name and revision of the protocol the server is using.
||The name and revision level of the web server
As we said, most of this information will
not be useful to your script.
In fact, for the most part, you will only
want a few of these variables in your script.
If it is a GET request, your script will
If this is a POST request, the script will
need CONTENT_LENGTH and will need to have the server send the body
of the HTTP message to it as standard input.
But what does a CGI script look like? I do
realize that this section went really fast and is pretty high
Well that is because a lot of what you need
to know will be discussed tomorrow. So let's stop here.