Writing programs to process the forms


The ACTION directive in the <FORM> tag points at the program which will be executed by the server using the field information provided by the form. Using the preferred POST method, the program receives a stream of data through STDIN of CONTENT_LENGTH length.

This stream of data looks like this:

Therefore, your program needs to read from STDIN CONTENT_LENGTH bytes into a variable, and parse the stream into individual fields useable by your program. Your program must also return the CONTENT_TYPE of the information that the program returns to the requesting browser. This describes the type of data the browser will receive upon submitting the form. This is usually a content type of text/html.

Here is an example of a CGI script written in Perl.

The de facto standard library for creating CGI scripts in the Perl language is cgi-lib.pl.


[Forms] [Outline] [ISINDEX]