Simple CGI formsThe Common Gateway Interface runs an external program (a 'CGI script') as a result of a client request and returns the output of the program to the client. CGI defines the interface between the web server and the CGI script. Useful references: The last example might have included some dynamic elements, but it wasn't very useful. We'll now look at how we can ask users for information and then act on it to generate personalized Web pages. HTML Forms are the standard method of requesting information from the user. They provide a simple means of displaying text boxes, check buttons and radio buttons within the browser. For full information on HTML forms consult the HTML specifications at the World Wide Web Consortium (http://www.w3.org/). Example: A basic HTML Form
The important lines in the HTML are:
This defines the CGI program to run when the submit button is pressed. It also defines how the data is passed to the CGI program. There are two methods which data can be passed to CGI programs, GET and POST. POST is generally the more useful, and more widely used method so it's that which we'll use here. For a more complete list of differences between the two methods please consult the Zeus CGI Reference Document. And also:
These define two text input boxes labelled name and email. These labels are used in the CGI program to read the associated values. CGI Form Code The PERL script to process the form information is a little more complicated than the previous examples. The POST method writes data from the form straight to the CGI program through standard input, it also escapes some characters by prefixing them with %'s and converts other characters to their ASCII values in hexadecimal. Process Form CGI
|
Recently...
Other Resources
|





