Making Your Form Work with FormMail

The FormMail script that is installed on bama is fairly versatile. It will take information from a form, e-mail it to a specified address, and direct the user to a "thank you" page. However, it can also make sure that required fields are filled in, and it will allow you to customize the thank you and error pages. There are only a few things that you need to do to set up your form to work with FormMail.

Form Fields

The main part of setting up your form to use FormMail is making sure you have the proper fields in it. Some will be hidden fields, while some will be fields you may already have in your form.

Important: You must put in field names exactly as they appear! Changing the case, misspelling, or renaming a field will all cause your form not to work properly.

Remember that a field has a name that you give it when you set it up and it also has a value , which is usually filled in by the user. You can also set the default value, which is especially important in hidden fields, which the user cannot set a value for. When you are using a script like FormMail, you must make sure that the names of particular fields match what the script expects.

Hidden Fields

Hidden fields are used to pass information to the script that you don't want to be part of the visual form. These fields are not completely hidden; they are easily viewable by looking at the source code. Do not use hidden fields as an alternative to security!

The tag for a hidden field is simple, and is very similar to the tags you've already used:

<INPUT TYPE=hidden NAME="name" VALUE="value">

recipient

This is the only required field. This is how FormMail knows what e-mail address to send the information from the form to. Put "recipient" as the name and your e-mail address as the value.

<INPUT TYPE=hidden NAME="recipient" VALUE="emailaddress">

To prevent the FormMail script from being used to send spam, the recipient field is strictly limited. If you are using this to send e-mail to a non-bama.ua.edu address, you may get an "invalid recipient" message. If this occurs, contact the HelpDesk to have your recipient added. This will only by done for University of Alabama e-mail addresses.

subject

This is very useful if the form information is being sent to a mailbox that is used for other things, especially other forms! Put "subject" as the name and the desired subject line as the value. All e-mail from this form will have the subject line you specify.

<INPUT TYPE=hidden NAME="subject" VALUE="Put the Subject line here!">

required

If you want FormMail to do some simple form validation for you, simply tell it which fields must be filled in. If the form is submitted without all the required fields, the user will be directed to an error page, and the e-mail will not be sent. Put "required" as the name and a list of field names (separated by commas) as the value.

<INPUT TYPE=hidden NAME="required" VALUE="field1,field2,field3">

Visible Form Fields

These two fields may already be in your form in one way or another. If you want FormMail to use them, you need to make sure that they have the correct names!

  • The field that asks for the user's name should be called "realname"
  • The field for the user's e-mail address should be called "email"

Passing the Information to FormMail

To connect your form to the FormMail script, make sure the opening form tag looks like this:

<FORM ACTION="/cgi-bin/FormMail" METHOD=POST>

More Information

For more information about FormMail, please see the script's readme file. This will tell you how to further customize your form to use all of FormMail's capabilities.