|
|||||||||
![]() |
|
Processing input from fill-out forms
Fill-out forms are set up within HTML documents as described in
Chapter
If the form specifies METHOD="GET", the data will be
url-encoded in the URL as a query string (see
Section If the form specifies METHOD="POST", the data will be passed to the server in the body of the request and then from the server to the CGI script in the script's standard input stream. The length of the data is placed in the CONTENT_LENGTH environment variable and the CONTENT_TYPE environment variable will be set to application/x-www-form-encoded. The script should not try to read more data from the standard input stream than the number of bytes specified by the content length variable, as the stream will be connected to the server's output stream and, on some systems, if the server does not close its end of the stream, the script will hang waiting for more data to appear.
Fill-out forms consist of a set of fields. When the form is submitted
by the user, the browser sends the name and value of each field, for
all the fields that contain data (some fields may be empty). The
field names and values are url-encoded (see
Section
field1=1&field2=three+separate+words&field3=%7e contains three fields: field1, field2 and field3, with values: the numeric value 1, a string containing the text `three separate words', and a single encoded character (~). The process of decoding forms data consists of:
Form data may contain duplicate field names. This is permitted for multiple value selection fields: each selected value is sent as a name/value pair. Image button fields are sent as two separate name/value pairs, named field-name.x and field-name.y. Programs should not assume that the encoding of data received will be valid or that the field names and values received will be those that are expected.
![]() ![]() ![]() ![]() ![]() Next: Processing image map Up: Writing CGI scripts Previous: The cgiutils program
|
||||||
Copyright © 1996-2002 Ford & Mason Ltd |
![]() |