Services > Web Services > Interactive Forms

Using Interactive Web Forms at WHOI -new

These instructions are for users who are writing interactive forms for their WHOI Websites. If you are running your own web server you can implement your cgi scripts yourself. If your website resides on the WHOI server, there are several general purpose cgi scripts that you may use to test your forms and to email the form results to a designated recipient. The following instructions assume that you are using a forms-capable HTML editor (eg. DreamWeaver) or that you are coding directly in HTML.

There are four cgi scripts available:

  1. TestForm.cgi: This script will simply display in your browser the values entered in your form. Useful for testing forms.
  2. TestEmail.cgi: This script will email the values entered in the form to the email address specified in a hidden field. The script will also display the values back to the browser.
  3. HTMLEmail.cgi: This script works just like option #2 but the email is formatted HTML.
  4. Forms.cgi: This script is more complex and requires a more advanced understanding of cgi and perl. It allows you to have more control over the appearance of the email and response that is returned from the form.
1. Testing an interactive form

To test your form, go to the Action box in the form property window (or set the action= atrribute in the <form> tag) and enter:

http://www.whoi.edu/cgi-bin/whoi/TestForm.cgi
(note: this url has changed from the one I gave you in class)

When you fill out the form and select the submit button, the name-value pairs will be returned in an HTML page on your browser.

Here is a sample form.

2. Sending form results via email

If you want to have the name-value pairs emailed to a recipient, then edit your form as follows::

  • in the Objects window - Forms - Insert Hidden Field
  • name the HiddenField recipient and for the value, put the email address of whoever you want to receive the form data (eg. jallen@whoi.edu)
  • in the Properties window for the form, set the Action to http://www.whoi.edu/cgi-bin/whoi/EmailForm.cgi
  • extra: if you also include an input text field for the user's name (Name) and email address (Email) then these values will be included in the email message header as From: Name (Email)

Here is a sample form that will send email to the recipient entered in the text field. Note: In the instructions above the recipient is entered in a hidden field so that the user will not be able to reroute the form response to another email address.

3. Email sent as formatted HTML

If you want the the results of the form emailed to a recipient as formatted HTML, then follow the steps in #2 above but use http://www.whoi.edu/cgi-bin/HTMLEmail.cgi as the Action.

Here is a sample form that will send the response to recipient as an HTML formatted email.

4. Advanced cgi script for interactive forms response

This CGI script is used to email web form results to a designated email address as well as cc: the submitter.

See the documentation for a more complete description of how to use this script.

Here is a sample form (not yet available).