The University of Texas at Austin- What Starts Here Changes the World
Services Navigation


Generic Script

The most common use of a CGI script on the Web is to process data submitted through a form. The Web browser transmits this data in name/value pairs. The author of the form defines the name of each form element. The CGI script, generic.cgi, was written to help Web publishers check the name/value pairs created by fill-out forms.

Begin a Web form with <FORM ACTION="http://www.utexas.edu/teamweb/cgi-bin/generic.cgi" METHOD="POST"> and the script will return a Web page to your browser which contains the name of each element of your Web form which is returned by the browser followed by an equals sign and the value of that element. Most Web browsers do not return any values for checkboxes, radio buttons, or select menu items, which are not selected.

Sample Form Processed by generic.cgi

The HTML source of the form

<FORM ACTION="http://www.utexas.edu/teamweb/cgi-bin/generic.cgi" METHOD=POST>

<P><label for="name">What is your name? <INPUT TYPE="text" NAME="name" id="name" SIZE="30" VALUE="WebMaster"></label><BR />
<INPUT TYPE="checkbox" NAME="html" VALUE="likes" id="html" />
<label for="html">Check here if you like writing HTML.</label></P>

<P><INPUT TYPE="submit"><INPUT TYPE="reset"></P>

</FORM>

The form as it appears in the browser


The Web page returned by generic.cgi

name = WebMaster

The response from the CGI script has only one line, since Web browsers only submit information for checkboxes if the checkbox is selected. If the checkbox is selected, the response from the script will have two lines. To see how this works, try changing the values in the form above, and click the "Submit Query" button. You will need to use your browser's "back" feature to return to this page.

 

 

 


  Updated 2006 August 15
  Comments to TeamWeb