JHU Web Hosting Logo

Using form2.pl to Email Form Results

Note: JHUniverse does not have a SSL security certificate installed. Any forms on JHUniverse and any form that sends email as its result should not collect medical, patient identifiable, student, or financial information.

Using forms to collect information on your web site provides an easy way for your users to communicate with you. But what happen when the "Submit" button is pressed? Most often, the results of the forms are sent via email. JHuniverse provides a central script for this purpose called form2.pl.

Integrating form2.pl into your form is easy. Just set the action to:

<FORM METHOD=POST ACTION="/cgi-bin/form2.pl">

There are three hidden form inputs that tell form2.pl what to do. These customize the form response to your needs. Required Hidden Inputs:
  1. mailto - e-mail address of whom to send the results to
  2. subject - the subject of the e-mail message
  3. responseurl - the URL of the "Thank you for your comment..." page.
Here's a simple example with one field that sends mail to webhosting@jhu.edu with a subject of "Question":

<form method="post" action="/cgi-bin/form2.pl">
<input type="text" name="Question1">
<input type="hidden" name="mailto" value="webhosting@jhu.edu">
<input type="hidden" name="subject" value="Question">
<input type="hidden" name="responseurl" value="http://www.jhu.edu/wwwdev/thanks.html">
<input type="submit" value="Submit Application">
</form>

Notes:
The value for the responseurl hidden field should be a complete URL, like http://www.jhu.edu/wwwdev/thanks.html, not just thanks.html.

The form2.pl script returns its results sorted by alphanumeric order, so you can customize the order of the results by carefully naming your form fields something like 01_field1, 02_field2, etc.

The form2.pl script is restricted for use by Hopkins computers only.


Updated Monday, 28-Jul-2003 02:11:19 EDT -- webhosting@jhu.edu -- JHUniverse -- Technical Information