Publish Web Pages at UVM

Creating a Form with FormMail.pl

This document describes the basic features of the formmail.pl script, a program that lets you create a form to collect information on a web page and have it sent to you as an e-mail message. It assumes you have read "Creating a Web Form ."

Many web editors allow you to create forms. Check with your particular editor for the process. Netscape Composer does not have this feature, so you will have to learn a few HTML tags and create your form using a plain text editor like WordPad on Windows or SimpleText on Macintosh.

This page describes the tags you can use with your form. You can see an example, with some descriptive information, at:

A Form Example Using FormMail.pl


Important! Important! Important!

After you create your form you must FTP it to the server (zoo, www.uvm.edu, etc.) before you can test it. If you try to test it from your computer's hard drive it will not work. Without this restriction, non-UVMers could create forms that run off our server, potentially overburdening it.


To Begin

  1. Create a new web page. Include your title, page color, opening text or any non-form information.
  2. Save the file.
  3. Open WordPad, SimpleText or any other text editor.
  4. Open the file you just created.
  5. Move to the place where you want the form fields to begin.

The First Tag

The first tag of the FORM section is the FORM tag itself. It describes the ACTION and identifies the program to be used to process the form. When you use FormMail.pl, that tag looks like this:

<FORM action="http://scripts.uvm.edu/cgi-bin/FormMail.pl" method="POST">

Fields Necessary to All Forms

You can create forms with any number of fields but there are two fields that you should include. One field allows people to reset the form (for example, if they have made a mistake in filling it out and want to clear all the information). The other lets them actually send the information. These are called the "Reset" and "Submit" fields. They appear as buttons in the form. The actual words that appear on those buttons can be any word or phrase you like, that is, they do not have to say submit or reset. For example:

<INPUT TYPE="submit" NAME="submit" VALUE="Register for the Conference Now!">
<INPUT TYPE="reset" VALUE="Reset">

will result in two buttons that look like this:

The Special FormMail.pl Field You Must Include

The only field that is absolutely required when using FormMail.pl, and must be named with this specific name, is the "recipient" field. This is the field that tells the program to whom it should send the e-mail message containing the collected information. Since this tag is hidden, you can place it anywhere between the opening and closing FORM tag. The tag looks like this:

<INPUT TYPE="hidden" NAME="recipient" VALUE="somebody@uvm.edu ">

Note that the word "recipient" is in lower case. Also, you can have the collected information sent to multiple e-mail addresses by simply including those addresses separated by commas like this:

<INPUT TYPE="hidden" NAME="recipient" VALUE="somebody@uvm.edu,someone.else@uvm.edu,another.person@uvm.edu ">

Other FormMail.pl Fields That are Useful

The "sort" Field

If you do not specify which order the information should be returned to you, it may or may not come back in the order you created in your form. To ensure that the information is listed in the e-mail message the way you want it to be, use the "sort" field. You can choose to have the fields sort alphabetically or in any order you specify. To sort by a set order, include the word "order" as the first part of the "VALUE" followed by the field names in the order you wish them to appear. For example, if I had fields on the web page named: LAST, FIRST, DEPT, and PHONE but I wanted them to appear in the e-mail message in this order: DEPT, PHONE, FIRST, LAST, I would include this tag:

<INPUT TYPE="hidden" NAME="sort" VALUE="order:DEPT,PHONE,FIRST,LAST">

If I simply wanted the fields returned in alphabetical order, that is, DEPT,FIRST,LAST,PHONE, I would use this tag:

<INPUT TYPE="hidden" NAME="sort" VALUE="alphabetic">

The "required" Field

FormMail.pl provides several functions. One of them is the ability to require a person to fill in certain information before allowing the form to be sent. For example, you may have created a conference registration form. You would like to ensure that people don't forget to include their name and e-mail address before sending it in. FormMail.pl's "required" field can help. When you use this field you specify which fields must be filled out before the form can be sent. If those fields are not filled out, FormMail.pl will return an error message to the person filling out the form. It will tell them which fields were missed and ask them to fill in those fields.

For example, if I had a form with the fields NAME, DEPT, and EMAIL, and I wanted to be sure the NAME and EMAIL fields were filled in before the form could be sent, I would include this tag:

<INPUT TYPE="hidden" NAME="required" VALUE="NAME,EMAIL">

The "subject" Field

Generally, the e-mail message that is sent as a result of processing the form contains the Subject line: WWW Submission Form. You may prefer a different Subject line so that you can easily differentiate your regular e-mail from messages that are the result of a form submission. You can specify any Subject line you choose with this field:

<INPUT TYPE="hidden" NAME="subject" VALUE="Whatever you would like the subject line to read">

Other Useful Fields

The fields described above are just a few of those available for use with the FormMail.pl script. Others include a field that lets you use your own web pages in place of the default web pages that are part of this script. For example, when someone fills in the form and sends it they see a very simple web page that repeats back the information they have sent. Or when they forget to fill out a required field, they get back a web page that simply tells them which field they have forgotten. If you do not like these simple default pages you can create your own web page and have the script return that page instead of the default.

Another field allows you to specify whether you want field names sent when the fields are blank. You can also collect more information about the browser and location of the person submitting the form.

These and other fields are described by the author of the FormMail.pl script, and are available on the UVm web site at:
http://www.uvm.edu/cit/web_publishing/?Page=.%2Fformmail.html&dir=.


See all these options, as well as examples of form tags in:

A Form Example Using FormMail.pl


Last revised: 02 May 2001
Author: Hope Greenberg
Computing and Information Technology, http://www.uvm.edu/cit/