link to UTHSC-H's home page

oac banner

[ UTHSC-H Home ] . [ Search Files ] . [ Administrative Documents ] . [ For Faculty/Staff ] . [ For Students ] . [ For LAN Managers ] . [ OAC A to Z ]


formhandler.pl

Contents:

Purpose
formhandler.pl takes the output from an HTML form located on www.uth.tmc.edu and processes it according to a saved set of options. These options are keyed to a formcode that is must be requested from Academic Computing, and is included in the file. The processing options currently include the output format and delivery method. Formcodes will not be issued to users on servers other than www.uth.tmc.edu.


User Configuration
To use formhandler, users must:
  • request a formcode to identify the correct set of processing options when a form is submitted. Formcodes may be requested via the form below.
  • configure their HTML forms to use the formhandler.pl CGI and the requested formcode.


link to OAC home page

link to oac services page

link to oac teams page


Formcode Request

Requested formcode (no spaces) :

Contact email Address (in case of questions):

Form information using this formcode should be:

Address for Emailed results (if applicable):

File name (including directory) for saved results or results mailed once per day:

Data format (see examples):

Field Sorting:

Delimeter:

HTML Return Page: URL that will be returned after the form is submitted:

Comments regarding this submission:

HTML Form Configuration
To configure a form to use formhandler:
  • Make /cgi-bin/formhandler.pl the ACTION for your form. The METHOD may be either GET or POST.


  • To use semicolon as a delimeter Make /cgi-bin/formhandler1.pl the ACTION for your form.

  • There must be a field (typically a hidden field) named formcode whose value is the code name requested for handling the form. Unless there is a conflict with an existing code, the code will be assigned as requested. Note that the code specifies how a form is handled, but does not have to be unique to each form. This means that all form results that are mailed to a single address in a single format could use the same form code. Similarly, a single file could be set up to receive the output of multiple forms, which might use a hidden form identifier field to distinguish between forms. Using a single code for multiple forms allows a user to create forms that can be active immediately, without having to wait for administrator intervention.

  • An example of the above form configuration lines would be (variables shown in italics):

  • <FORM ACTION="/cgi-bin/formhandler.pl" METHOD=POST>
    <INPUT TYPE="hidden" NAME="formcode" VALUE="myformcode">
  • Note that any data file that receives data must be writable to the www user.
  • You have the option of specifying a response page for each form code. This is a page returned to the user after the form is processed. If no page is specified, a default 'thanks for the input' page is returned that includes a link to the referring form.
Output Examples
Form data may be returned in one of three formats. This list gives examples of each type.
  • HTML: Data is returned as an Unordered List of the field names, with field values saved as an unordered list item nested beneath the field name. For example:
    • fieldname1
      • value1
    • fieldname2
      • value2 value2 value2 value2
    • fieldname3
      • value 3
  • Named Pair: Data is returned as "fieldname = value", with one pair per line. For example:

fieldname1 = value1
fieldname2 = value2 value2 value2 value2 value2 value2
fieldname3 = value3

  • Unformatted: Data is returned as a list of field values enclosed by double quotes, separated by commas. The values are returned in the field sort order. For example:

    "value1", "value2 value2 value2 value2 value2 value2", "value3"

Administrator Configuration

Formcodes (as described above) are created in /usr/local/etc/httpd/cgi-bin/formhandler.cf by the owner of the file or a root user. The entry is created between the %FHConfig = ( and the corresponding );. This entry is in the form:
 
 "formcode" => "format-style,field_sort_order, output_method,output_file,email_address, response_link",

where:

  • formcode is the assigned/requested code that identifies the form. This must be unique within the configuration file.
  • format-style is the format for the returned data. It may be one of the following values (see examples ):
    • html: the field names are returned formatted as an unordered list (HTML tag <UL>), with the field values included as an embedded unordered list below the field name.
    • named-pair: the data is returned as fieldname = fieldvalue, with one name/value pair per line.
    • dump: only the field values are returned, enclosed in double quotes and separated by commas. The fields are returned in the order specified by field_sort_order. For example, the data may appear as "field value 1","field value 2","field value 3"
  • field_sort_order specifies whether the returned data is to be sorted, and in which direction. Legal values are:
    • forward: field names are sorted in ascending order.
    • reverse: field names are sorted in descending order.
    • none: fields are unsorted and should appear in the order they occur in the form.
  • output_method specifies whether data is to be e-mailed to a given address, saved to a given file, or both. Legal values are:
    • mail: data is sent via email to the address specified in field 5, email_address
    • file: data is appended to the file specified in field 4, output_file
    • both: both the above actions are taken
    • batch_mail: data is saved to a file that is automatically mailed once per weekday if the filesize is greater than zero. This is handled by /usr/local/etc/form.deliver
  • output_file specifies the full path name of the file to which data will be appended if outputmethod is set to file or both. The file must be writable to the 'www' user.
  • email_address specifies the email address to which data will be sent if output_method is set to mail or both.
  • response_link specifies a web page that will be returned to the browser after the form has been processed. If no form is specified, the script returns a 'thank you' message and a link to the previous page.
Created: July 22, 1997
Last updated: 8th June 2004 - go
Office of Academic Computing
Updated March 1, 2007

Phone: 713.500.3501    7000 Fannin St., Houston, Texas 77030