Email Form Handler
How to use the email form handler cgi
Formatting the form and the feedback
Additional Features
Sample form
The form handler available on the UAF web server is called email. This
is a cgi (Common Gateway Interface) program that formats information
from a form and emails it to an email address given in the form. When
finished, it sends the user a screen telling them that the form has
been submitted, and reports the information sent.
How to use the email form handler cgi
The cgi is called from within the <form> tag. The syntax should
look like this:
<form action="http://cgis.uaf.edu/cgi-bin/email" method="post">
This handler requires at least three inputs to work. First, name
and mail are required inputs. For example:
| Name:
The html code for this textbox should be:
<input type="text" name="name">
|
Email:
The html code for this textbox should be:
<input type="text" name="mail">
|
IF YOU WISH YOUR FORM TO BE ANONYMOUS, the name and mail inputs can
either have the initial value set to anonymous, e.g. <input type="text"
name="name" value="anonymous">, or these inputs
can be hidden with a value set to anonymous; e.g. <input type="hidden"
name="name" value="anonymous">
A hidden input called mailto is also required. The syntax for this
is:
<input type="hidden" name="mailto" value="your
email address goes here">
Form results can be sent to more than one email address by separating
email addresses with a comma. PLEASE be careful of this - do not
use this cgi as a general mailer.
The cgi formats input items into Name = Value pairs and sends the resulting
message to an email address.
Formatting the form and the feedback
There are additional hidden inputs that will affect the return report
to the user, after the form has been submitted.
name: formname
html coding:<input type="hidden" name="formname"
value="your form name">
what it does: this is placed at the beginning of the email message to
indicate which form is being handled. This allows the end user to distinguish
which form is outputing the email, when there are multiple forms on
a site. The formname can be no longer than 14 characters.
Name: nexturl
html coding:<input type="hidden" name="nexturl"
value="http://a_url_on_your_site">
what it does: creates the url for a link that will appear on the submittal
report the user gets after successfully submitting the form. Used with
the nextdesc hidden input. Maximum length of url: 64 characters.
Name: nextdesc
html coding:<input type="hidden" name="nextdesc"
value="Text that will be associated with the url that creates a
link">
What it does: Creates the text for a link that will appear on the submittal
report the user gets after successfully submitting the form. Used with
the nexturl hidden input. Maximum length of description: 64 characters.
Name: redirurl
html coding:<input type="hidden" name="redirurl"
value="url where you want the user sent">
What it does: Will redirect the user to an alternate thank you page
on the departmental site when the form has been successfully submitted.
This replaces the default "Information submitted" form created
by the cgi, and the user will not have their input reported back to
them. Maximum length of url: 64 characters.
Additional features
name: formsub
html coding: <input type="hidden" name="formsub"
value="Subject of the form you are making">
What it does: Whatever is put in the value field of this input will
appear as the subject in the email program that you use when you receive
feedback from this form. Maximum length of subject: 64 characters.
Name: userhide
html coding: <input type="hidden" name="userhide">
What it does: By default, the user sees the submittal report upon submitting
their answers on the form. Userhide turns this feature off - when used,
the user will not see the answers they submitted on the default submittal
report.
Name: errurl
html coding: <input type="hidden" name="errurl"
value="http://some_url">
What it does: Adds this url as a link on the default error page, which
will take the user to a page that you make up, explaining what items
are required in your form, and why.
Name:R- (added before any input name)
html coding: <input type="text" name="R-phone">
What it does: This command at the beginning of any named input allows
the web developer to make that input required. In the example above,
phone is now required. The form cannot be submitted without something
in the phone textbox.
Name: H- (added before any input name)
html coding: <input type="text" name="H-street_address">
What it does: Similar to userhide, this turns off specific inputs, rather
than all inputs in the form. The example above would not return the
input street_address in the submittal report following submission
of the form.
Name: X- (added before any input name)
html coding: <input type="text" name="X-job_title">
What it does: This combines both the R- and H- command: it makes an
input both required and hidden from the user after form submission.
In the example above, it would make the input job_title required, and
would hide the results from the user on the submittal report page.
Name: formdir
html coding: <input type="hidden" name="formdir"
value="SDE"> ( any combination of the following letters,,
depending on what you want.) Maximum length: 8 characters.
What it does:
S will sort your Name = Value pairs by name, with the required fields
first.
D will report the name and mail pairs at the beginning of the message,
but remove any name and mail = value pair duplicates further down
in the email.
E will not report fields left empty by the user.
A will omit the lines in the beginning of the message which identify
the sender. This permits true anonymity on a form. When combined with
D, this will leave all indication of the sender out
of the message. At this time, this does not turn off the requirement
for a value in the name and mail fields, but they can be stuffed with
dummy values in hidden fields in the form so that the user doesn't
see them.
N will omit the entire introduction in the beginning of the message,
leaving only the Name = Value pairs. This option is handy for creating
messages which can be used as data entry for another program (like
a database).
T will replace the equal sign in the Name = Value pairs by a tab
character. This option combined with the N option allows the email
message to be used as a tab-delimited data file.
For an example of how to use the updated email CGI, you may
refer to the emailtest document. Be sure
to examine the source html file.
Please note that the mailto input in this example form has
been left for you to fill in so that you may mail your tests to yourself.
Please do not do this with forms you create - it is simply an example
form for you to learn from. This CGI should not be used
for a general mailer. |