|
 |
Formmail
CGI Instructions
The Formmail CGI
is a forms processor that emails the contents of a web form
to a specified recipient(s). To use the "formmail.cgi"
program on the NDSU web server, the form that is calling the
program must also be on the NDSU web server.
Use the following
instructions to incorporate the Formmail CGI script into your
forms. In each section you will find instructions on how to
use Dreamweaver to accomplish each task, and you will also find
the HTML coding that would result. If you are comfortable with
HTML and would prefer to do a quick copy and paste of the needed
code, please visit the previous Formmail
CGI instructions.
Insert
a Form into your Web Page:
First of all, you must invoke the Formmail CGI program by including
the following line in your web file's HTML code:
<FORM action="http://www.ndsu.nodak.edu/cgi-bin/formmail.cgi" method="POST">
For those of you who "don't do HTML," you can accomplish
the same thing using Dreamweaver by inserting your cursor where
you want the form to start and choosing INSERT >
FORM. A box will appear on your screen, and the Properties
window will change. In the Properties window, enter "/cgi-bin/formmail.cgi"
into the ACTION box, and leave the METHOD
as POST. All of the form's fields must reside
within this box.
Insert
the Recipients Field:
There is only one required field, the "Recipients"
field, in which you specify the person or persons who will receive
the results of the submitted web form. To add the "recipients"
field to your form, place your cursor inside the form box and
choose INSERT > FORM OBJECT > HIDDEN FIELD.
In the changed Properties window set NAME to
be "recipient" and VALUE
to be the full email address of the person(s) who will receive
the form results. If entering multiple recipients, separate
each email address with a comma but not an extra space.
Please note that
you can only use "@ndsu.edu" email addresses
in this field. If the recipient normally uses a different email,
such as Groupwise, he/she will have to use a "@ndsu.nodak.edu"
email address here and then set the NDSU email address to automatically
forward all mail to the Groupwise email address. (You can set
the forwarding of your email on the http://enroll.nodak.edu
site.)
The resulting HTML coding for the recipient field will look
like:
<INPUT TYPE="hidden" NAME="recipient" VALUE="your.name@ndsu.edu">
Insert
Optional Fields as Needed:
The following fields
are not required, but may make your form and its results more
effective. Please note that fields that are not "hidden"
should have Labels so that the user will know what goes into
the field. Example: Before the email field, you might display
"Please enter your email address here:"
- SUBJECT
- The subject field will allow you to specify the
subject that you wish to appear in the e-mail that is sent
to you after this form has been filled out. If you do not
have this option turned on, then the script will default to
a message subject: WWW Form Submission.
To add a "Subject" field in Dreamweaver, place your
cursor inside the form box and choose INSERT >
FORM OBJECTS > HIDDEN FIELD. In the Properties
window set NAME to be "subject"
and VALUE to be whatever you want the subject
of the email to be. The HTML equivalent is:
<INPUT TYPE="hidden" NAME="subject" VALUE="The
subject of your email goes here">
- EMAIL
-
This form field will allow the user to specify their return
e-mail address. If you want to be able to return e-mail to
your user, I strongly suggest that you include this form field
and allow them to fill it in. This will be put into the From:
field of the message you receive.
To add an "Email" field in Dreamweaver, place your
cursor inside the form box and choose INSERT >
FORM OBJECT > TEXTFIELD. In the Properties window
set TEXTFIELD to be "email"
and verify that the type is "single line."
The HTML equivalent is: <input name="email"
type="text" id="email">
- REALNAME
- The realname form field will allow the user to
input their real name. This field is useful for identification
purposes and will also be put into the From: line of your
email message header.
To add the "realname" field in Dreamweaver, place
your cursor inside the form box and choose INSERT
> FORM OBJECTS > TEXTFIELD. In the Properties
window set TEXTFIELD to be "realname"
and verify that the type is "single line."
The HTML equivalent is: <input type=text name="realname">
- REDIRECT
- After the visitor submits your form, you normally
send them a web page that thanks them for their participation
and assures them that the submitted information was received.
If you wish to redirect the user to a custom page, rather
than having them see the default response page, you can use
this hidden variable to send them to your "Thank-you"
page.
To add a "redirect" field in Dreamweaver, place
your cursor inside the form box and choose INSERT
> FORM OBJECTS > HIDDEN FIELD. In the Properties
window set NAME to be "redirect"
and VALUE to be the complete URL of your
custom response page, including the "http://" at
the beginning of the URL.
The HTML equivalent is:
<input type=hidden name="redirect" value="http://www.ndsu.edu/ndsu/??/??.html">
- REQUIRED
-
You can require certain fields in your form to be filled in
before the user can successfully submit the form. Simply place
all field names that you want to be mandatory into this field,
separated by commas. If the required fields are not filled
in, the user will be notified of what they need to fill in,
and a link back to the form they just submitted will be provided.
To add a "required" field in Dreamweaver, place
your cursor inside the form box and choose INSERT
> FORM OBJECTS > HIDDEN FIELD. In the Properties
window set NAME to be "required"
and VALUE to be the comma- separated list
of fields that are required.
The HTML equivalent is: <input type=hidden name="required"
value="email,realname"> (Your list of
required fields may vary from this example!
- SORT -
This field allows you to choose the order in which you wish
for your variables to appear in the e-mail that FormMail generates.
You can choose to have the field sorted alphabetically or
specify a set order in which you want the fields to appear
in your mail message. By leaving this field out, the order
will usually be the same order as they appeared in the form.
To add a "sort" field in Dreamweaver, place your
cursor inside the form box and choose INSERT >
FORM OBJECTS > HIDDEN FIELD. In the Properties
window set NAME to be "sort".
If you want to sort by a set field order, VALUE
will start out as "order:" followed
by the field names separated by commas. If you want to sort
the fields alphabetically, insert the form as described above,
but set VALUE equal to "alphabetic".
The HTML equivalent is:
To sort alphabetically: <input type=hidden name="sort"
value="alphabetic">
To sort by a set field order: <input type=hidden
name="sort" value="order:name1,name2,etc...">
- Note that in your
particular form, you'll add other fields according to the
purpose of your form for the data fields that you need.
Insert
Advanced Fields, if You Wish:
There are more defined
form fields available for the FormMail program that are not
normally used. If you are interested in using these advanced
fields, please link to the FormMail
Advanced Fields page for further instructions.
Insert
Submit and Clear Buttons:
At the bottom of
your form, within the dotted form box, you will need to insert
a Submit button, or your users will not be able to submit their
data to you. You may also include a Clear button that clears
all the answers from the fields, giving the user a fresh start
to the form.
To add a button in Dreamweaver, place your cursor inside the
form box at the end of the form and choose INSERT >
FORM OBJECTS > BUTTON. In the Properties window,
choose either "Submit form" or "Reset
Form", depending on whether this is a submit button
or a clear button. You can also change the LABEL
that will appear on top of the button to something other than
"submit" or "clear" if you wish. You can
even specify a phrase such as "Send my answers."
The HTML equivalent is:
<INPUT TYPE="submit" NAME="Submit" VALUE="Submit
Form">
<INPUT TYPE="reset" VALUE="Reset Form">
followed by the </form> tag.
Summary:
If you insert the
typical amount of code explained below, you will have code
like this at the start of your input fields:
<FORM action="http://www.ndsu.nodak.edu/cgi-bin/formmail.cgi" method="POST">
<INPUT TYPE="hidden" NAME="recipient" VALUE="your_name@ndsu.edu">
<INPUT TYPE="hidden" NAME="subject" VALUE="The title of your email goes here">
<INPUT TYPE="hidden" NAME="sort" VALUE="order:realname,email">
<INPUT TYPE="hidden" NAME="required" VALUE="realname,email">
<INPUT TYPE="hidden" NAME="missing_fields_redirect" VALUE="http://www.ndsu.nodak.edu/directory/oops.htm">
<INPUT TYPE="hidden" NAME="redirect" VALUE="http://www.ndsu.nodak.edu/directory/thanks.htm">
And code like this
at the end of your input fields:
<INPUT
TYPE="submit" NAME="Submit" VALUE="Submit Form">
<INPUT TYPE="reset" VALUE="Reset Form">
</FORM>
|