Using HTML Forms on Ohlone College Web Pages - Web Center

Shortcuts for Web Team:

Web forms (HTML forms) allow you to receive information from your site visitors via email. First, learn the basics of creating HTML forms for your website. Then, configure your HTML form to work with the Tectite FormMail form processing script (with built-in spam-prevention!) that is already installed on the main Ohlone College web server. You do not need to install the script in order to use it.

[The previously-used NMS Formmail script (formmail.pl) is no longer supported by the Web Team (instructions are still available but using it is not recommended).]

Basics of HTML Forms

Basics of Connecting Your HTML Form to Tectite FormMail

A "form processing script" accepts data from an HTML form and sends the data to one or more specified email addresses.

FormMail uses hidden fields in the HTML form to set the recipients of the email message as well as a number of other helpful configuration parameters (such as subject line, required fields, and the web page to be displayed after the user submits the form).

Tell the <form> to use the Tectite FormMail Script

To use the Tectite FormMail script, set the "action" attribute of the <form> tag to:

http://www2.ohlone.edu/tectitefm/fm.php

For example:

<form name="myform" method="post" action="http://www2.ohlone.edu/tectitefm/fm.php">

Then, set the hidden <input> tag for "recipients" to the desired email alias as discussed below.

Required Form Field: recipients

Only the "recipients" hidden <input> field is required by the Tectite FormMail script. Here is an example which uses an alias for the recipient's email address (see information about aliases):

<input type="hidden" name="recipients" value="a_and_r" />

If you leave the "recipients" field out of the form, FormMail will fail with an error of "no valid recipients".

Aliases for recipients' Email Addresses

To protect email addresses from being harvested by spambots and as an additional measure to ensure no one outside Ohlone College uses the Tectite FormMail script, obfuscated email addresses (aliases) are used for the "recipients" field. The Web Team maintains a list of aliases for use with the FormMail script.

To check whether you already have an alias for the "recipients" field of your HTML form or to request an alias, contact the Web Team. An alias can be created for one or more email addresses.

If the recipients value you want to use is not on the list of aliases, FormMail will fail with an error of "no valid recipients".

How to Select Multiple "recipients"

The use of the square brackets is required to choose multiple <select> options.

<select name="recipients[]" multiple="multiple">
  <option value="acad_aff">Academic Affairs</option>
  <option value="bus_off">Business Office</option>
  <option value="coun_dept">Counseling Department</option>
  <option value="stu_svcs">Student Services</option>
</select>

Converting from the old NMS Formmail Script (formmail.pl)

If you are converting to Tectite FormMail from NMS Formmail, you must change the name of the "recipient" hidden form field to "recipients" and replace all spaces in the value of the "recipients" field to an underscore (_). For example:

<input type="hidden" name="recipient" value="john and mary smith" />

becomes

<input type="hidden" name="recipients" value="john_and_mary_smith" />

Configuring Checkbox Fields in Your HTML Form

If you use checkbox fields in your HTML form, the Tectite FormMail script requires the use of empty square brackets at the end of the value of the "name" attribute for the <input type="checkbox"> field. For example (using an ordered list (<ul>) as is appropriate for a list):

<ul>
  <li><input type="checkbox" name="FavoriteFruit[]" id="apple" value="Apple" />
    <label for="apple">Apple</label></li>
  <li><input type="checkbox" name="FavoriteFruit[]" id="banana" value="Banana" />
    <label for="banana">Banana</label></li> 
  <li><input type="checkbox" name="FavoriteFruit[]" id="orange" value="Orange" />
    <label for="orange">Orange</label></li> 
  <li><input type="checkbox" name="FavoriteFruit[]" id="plum" value="Plum" />
    <label for="plum">Plum</label></li>
</ul>

...which looks like this:

Use CSS to turn off the list bullets:

Important: If you do not use the empty square brackets, Tectite FormMail will record only the value of the last checked checkbox. For example, if the user checked Apple and Orange and Plum, only the value of Plum will be included in the email message.

By the way, if you don't recognize the <label> field, learn about Creating Accessible Forms at WebAIM.

Helpful Form Fields (optional)

There are two <input> fields that get special treatment by FormMail:

  • email - If one of the things you're asking the user to fill in is their email address and you set the name attribute of that <input> tag to "email", FormMail will use the value entered by the user in the From: field of the email message generated.

    <input type="text" name="email" />

    If the field for the user's email address is not named "email", the email field can be derived as follows (see also advanced form fields):

    <input type="hidden" name="derive_fields" value="email=Email_Address" />

  • realname - If one of the things you're asking the user to fill in is their full name and you set the name attribute of that <input> tag to "realname", FormMail will use the value entered by the user in the From: field of the email message generated.

    <input type="text" name="realname" />

    If you are asking for the user's first name and last name separately, the realname field can be derived as follows (see also advanced form fields):

    <input type="hidden" name="derive_fields" value="realname=First_Name+Last_Name" />

Recommended Form Fields (optional)

The following hidden fields can be used to set additional configuration parameters:

  • email (see Helpful Form Fields above)

  • subject - The subject line for the email that is sent to the recipients. For example:

    <input type="hidden" name="subject" value="Athletics Comment Form" />

  • required - A list of fields the user must provide, together with a friendly name. The field list is separated by commas, and you append the friendly name to the field name with a colon (:). For example:

    <input type="hidden" name="required"
    value="fname:First Name,
    lname:Last Name,
    email: Email Address,
    comments: Comments or Questions">

  • good_url - The URL of the web page to display after the form has been successfully processed by FormMail. For example:

    <input type="hidden" name="good_url" value="http://www2.ohlone.edu/your/path/formthanks.html" />

Advanced Form Fields (optional)

  • derive_fields - A mechanism for deriving form fields by concatenating other form fields (see Tectite How-to for Deriving Fields from Other Fields).

    Operators are:

    • + (plus sign) joins fields together with a single space, but only if the following field is not empty
    • . (period) joins fields together with no space added between
    • * (asterisk) joins fields together and always adds a single space between

    Example with multiple derive_fields options set:

    <input type="hidden" name="derive_fields" value="realname=firstname+lastname, email=EmailAddress, fullphone=area.phone, address=street*suburb" />

    Spaces around the equal sign (=), around the plus sign (+), and after the comma (,) are optional.

  • mail_options - A list of comma-separted options to control FormMail when sending email. Options include (full list):

    • Exclude - Provides a semicolon-separated list of fields to exclude from the form results email. Example: value="Exclude=field1;field2;field3"
    • KeepLines - Some fields, such as textareas, may contain embedded newlines (also known as line breaks, returns). Normally, FormMail strips newlines from fields. If you specify this option, FormMail will keep the newlines. Example: value="KeepLines"
    • NoEmpty - Normally, FormMail includes all fields sent from the user's browser even if they are empty. This option tells FormMail to exclude empty fields from the email it sends you. Example: value="NoEmpty"

    Example:

    <input type="hidden" name="mail_options" value="KeepLines" />

    Example with multiple mail_options set:

    <input type="hidden" name="mail_options" value="KeepLines, Exclude=submit;realname, NoEmpty" />

Advanced Features of Tectite FormMail (Optional)

The Tectite FormMail form processing script has many features and can be configured in a number of different ways. To use the advanced features, you will probably need to install and configure the Tectite FormMail script on your own website instead of using the FormMail script installed on the web server by the Web Team.

The Web Team is available to confer with you about your needs. However, the Web Team can provide only limited assistance.

Documentation, FAQs, and How-To Guides on the Tectite FormMail website are very thorough. In addition, you can use the Tectite FormMail Forum (message board) for support. Tectite also provides fee-based support - please confer with the Web Team before paying for support!

Some of the advanced features of FormMail include (full list):