The ROCK Linux project has been discontinued in 2010. Here are the old data for the historical record!
CGI Made E-Z with cgi-postin Contents: * [1]Introduction * [2]Review of HTML Forms * [3]Review of Forms Handling under Gn * [4]Form Processing with cgi-postin * [5]Conclusion * [6]Appendix A: Links to Examples * [7]Appendix B: Perl Support _________________________________________________________________ Introduction Fill-out forms are a popular feature on the World-Wide Web. Gn, like any good Web server, supports them. This support comes through the Common Gateway Interface (CGI). CGI processors can be tedious to write. The most cumbersome part is retrieving and decoding the form data. The cgi-postin utility solves this problem. It lets you write CGI processors as sh(1) scripts, and not have to worry about the intricacies of the CGI interface. This note explains how to use cgi-postin to write CGI processors running under the gn HTTP server. We will review briefly how forms are created. We will discuss how the Web client and gn server coordinate to process a form. Finally, will construct a CGI processor based upon cgi-postin. The cgi-postin utility is freely available. It was written by Chip Rosenthal. The most recent version may be downloaded from [8]ftp.unicom.com:pub/gn-tools/cgi-postin.c. Review of HTML Forms Forms are created in HTML documents with tags such as:
The two attributes, METHOD and ACTION, say what to do with the form. The METHOD directs the client how to pass the form data back to the server. The ACTION is a URL to the processor that handles that data. There are two methods available: post and get. The get method transmits the form data within the URL. It requires cooperation from the HTTP server to extract the data. The post method transmits the form data in-band, and allows the CGI processor to load it (usually) from its standard input. Here, we are concerned only with the post method. That's because cgi-postin was designed for it. Otherwise, we would have called it cgi-getin:-). Lack of get support shouldn't be a problem; you probably want to use just the post method. If you have never created an HTML form, before you go any further, you should read the [9]Fill-Out Form Support for NCSA Mosaic tutorial. It describes the elements available to construct forms, and provides some very good examples. You will want to use the ``View Source'' feature of your Web browser to see how the examples are constructed. Review of Forms Handling under Gn There are two pieces to [10]a World-Wide Web form. There is [11]the HTML source to the form, and there is the backend CGI processor. The CGI processor receives the form data from the client, performs some actions, and returns some resulting document. In this section we will examine the interface between these two pieces, in preparation for the next section, where we will tackle the chore of writing a CGI processor. A submit button is placed on a form with something like: When the submit button is selected, the client performs several transformations on the data. We won't bother going into those details here. Normally, unmunging the form data is one of the most tedious parts of CGI processing. The cgi-postin utility does all that, so you don't have to worry about it. After the data has been munged, the client invokes the URL associated with the form. Again, this association was made in the original FORM tag. If, for example, we created the form with: