|
When you create a form, you can choose to have the form input sent to a
specific person. You can also provide the visitor with a message which
confirms that the form has been sent. There are several ways to send this
input and to provide confirmation. You can use one of the methods listed
below. (Note: These forms are not operational.)
Mailto With No Confirmation (input
received as attached file)
Use Mailto as the action for the form. For example:
<FORM METHOD="post"
ACTION="mailto:abc@psu.edu?
subject=Sample+Form+Mailto">
...rest of form code...
</FORM>
Here's an example of a web form that uses Mailto:
Here's what happens when a visitor clicks the Submit button:
username=Kermit+D.+Frog&ice_cream_flavor=vanilla
-
The visitor stays on the same page and does not receive a confirmation
message. (Although in the status bar, a message flashes very quickly
that indicates that the form was sent. Most visitors will probably not
notice this status message.) As a result, the user may think that the
form was never sent and then may re-submit the form. To help
alleviate this possible confusion, it's best to display some type of
confirmation message that says that the message has been sent.
Mailto with No Confirmation (input received within email
message)
Use Mailto as the action for the form and include the ENCTYPE tag to send the
input as plain text. For example:
<FORM METHOD="post"
ACTION="mailto:abc@psu.edu?
subject=Sample+Form+Mailto+Enctype" ENCTYPE="text/plain">
...rest of form code...
</FORM>
(The information in the opening FORM tag is typed on one
line.)
Here's an example of a web form that uses the ENCTYPE attribute:
Here's what happens when a visitor clicks the Submit button:
Date: Wed, 27 Oct 1999 180649 -0400
From: Kermit D. Frog
To: abc@psu.edu
Subject: Sample+Form+Mailto+Enctype
Content-type: text/plain
username=Kermit D. Frog
ice_cream_flavor=chocolate
-
Just as in the method described above, the visitor stays on the same page
and does not receive a confirmation message. As a result, the user may
think that the form was never sent and then may re-submit the form.
Note about Confirmation Messages
There are several different ways that you can display a confirmation
message. Some methods require that you use a CGI/Perl script.
Other methods use a scripting language like Javascript. The methods that
follow provide an example of each method.
Using Javascript & Mailto for Web Form
Confirmation (input received either as attached file or
within email)
With this method, a confirmation message is displayed by using Javascript in
conjunction with Mailto. (You can configure the form to either send the
input to you as an attached file or as plain text within an email message.
See the above methods for instructions.) Note that this method won't work
if a visitor's browser is configured so that it won't accept Javascripts or Java
applets.
Here's an example of a form that uses Javascript to provide a confirmation
message:
If you view the source code for this web page, you will see Javascript code
that is included:
-
within the opening FORM tag -
within the INPUT tag for the the
Submit button -
after the INPUT tag for the Reset button
Here's a sample of what the form section of the web page would look like:
<form method="post"
action="mailto:abc@psu.edu?
Subject=Sample+Form+Mailto+Confirmation"
onSubmit="alert('Form is being sent');">
<p>Name:
<input NAME="username" size="30"> </p>
<p>My favorite ice cream flavor is:
<select name="ice_cream_flavor" size="1">
<option value="vanilla">vanilla</option>
<option value="chocolate">chocolate</option>
<option value="strawberry">strawberry</option>
<option value="other">other</option>
</select>
</p>
<p><input type="submit" onBlur="doVerify()"
value="Submit">
<input type="reset" value="Reset">
<script LANGUAGE="javascript">
function doVerify()
{
location.href = "form-confirm.htm"
}
</script>
</p>
</form>
(The information in the opening FORM tag is typed on one
line.)
Here's what happens when a visitor clicks the Submit button:
-
A small alert box box pops up on the screen which says that the form is
being sent. -
The visitor is taken to a web page that further confirms
that the form was sent and thanks them for completing the survey. -
The
form input is sent to the designated person. This person receives an
email message that contains the form input. The input would look like
this:
Date: Wed, 27 Oct 1999 172655 -0400
From: Kermit D. Frog
To: abc@psu.edu
Subject: Sample+Form+Mailto+Confirmation
Content-type: text/plain
username=Kermit D. Frog
ice_cream_flavor=strawberry
Using a CGI/Perl Script for Web Form Confirmation
Web forms can be configured to use a CGI/Perl script on a web server.
Some scripts can format the input and place it in an email message. Other
scripts will take the input and convert it to a comma delimited file so that the
data can be imported into a spreadsheet or database.
The web form below uses a free CGI/Perl script called Formmail. (This
script is available from Matt's
Script Archives. In addition, this script is installed on a Penn
State web server so that Penn State faculty, staff, and students have ready
access to the script.) Formmail simply takes the form input and places it
within an email message. You can also configure the script to have the
information sent to you in a specific format and to provide the visitor
with a confirmation message. For example:
<FORM METHOD="post" ACTION=
"http://www.personal.psu.edu/cgi-bin/formmail.cgi">
<input type="hidden" name="recipient"
value="abc@psu.edu">
<input type="hidden" name="subject"
value="Sample Form using Formmail">
<input type="hidden" name="redirect"value=
"http://www.pserie.psu.edu/compcntr/webhints/
form-confirm.htm">
...rest of form code...
</FORM>
Here's an example of a web form that uses the Formmail script (which uses the
default configuration and provides a confirmation page):
The form input is sent to the designated person. This person receives
an email message that contains the form input. The input would look like
this:
Date: Wed, 27 Oct 1999 173203 -0400
To: abc@psu.edu
From: ()
Subject: Sample Form using Formmail
Below is the result of your feedback form.
It was submitted by () on Wednesday,
October 27, 1999 at 173203
------------------------------------------
username: Kermit D. Frog
ice_cream_flavor: other
------------------------------------------
Here's what happens when a visitor clicks the Submit button:
|