PROCESSING HTML FORMS
( Version 1.5 - Last modified:
2002-05-20 9:52 AM
)
<compiled by Jhinuk Chowdhury>
Question. I have created a form on a web page. How can I
send (or receive) the data input by users on my HTML forms to myself?
ANSWER:
There are three broadly separate methods of doing this:
- using the mailto: command;
- using a CGI (common gateway interface) script;
- using technologies such as ASP,
JSP,
PHP or CFML.
Here, we will discuss only methods #1 and #2.
First method:
The method is to use the mailto: command as the value of the ACTION
of the form.
When using mailto: in forms, the method should be set to POST and the
mailto: command is inserted alongside the action tag as shown below:
<form method=post action="mailto:you@somewhere.com"
enctype="text/plain">
. . . (form data goes here) . . .
</form>
Using the enctype="text/plain" command in the form tag will
ensure that the data is posted in the body of the email and not in the
subject line.
Using this method, you may add multiple recipients, and add additional
mailto: commands such as CC (carbon copy), BCC (blind carbon copy) and
so forth. For the complete list of options, see http://www.network23.com/hub/mailto/default.html.
This method is simple, but unreliable. Some email programs do
not respond properly to the mailto: command. Also, some email programs
do not understand the commands required for the CC and BCC features. Consequently,
the mailto: command and its features are NOT recommended for processing
of forms in a mission critical situation. Finally, the user may not have
set up his/her browser for email. It is inadvisable to use the mailto:
command unless you have total confidence that all users will (a) set up
their browsers for email correctly, and (b) the particular email program
they will use can and will handle all features of the mailto: command.
Second method:
This is likely the most prevalent method of processing forms. CGI scripts
are freely available on the web. However, you will need a CGI-enabled
web server to serve the CGI scripts. (If you have a cgi-bin subfolder
on your web server space, you likely have CGI capability.) For web servers
hosted on Unix machine and/or running Apache, this is a common solution.
[If you have no CGI capability on your server, click here.]
FormMail, the most popular CGI script for
processing a form to email, is available at http://www.worldwidemart.com/scripts/formmail.shtml.
This will parse the results of a form and send them to the specified user.
This script has many formatting and operational options, most of which
can be specified through the HTML form. A tutorial for this relatively
easy script is maintained by Brant Burgiss at http://www.appbuild.com/formmail_help.html.
Experts in the Dreamweaver community have recently begun to discourage
the use of this version of FormMail because of security concerns. (See
http://www.monkeys.com/anti-spam/filtering/formmail.html
to read about some of the issues.) The recommended
version of FormMail is available at ftp://ftp.monkeys.com/pub/formmail/1.9s/.
The following extensions of FormMail have the capability to LOG the submissions
as well.
BFormMail (at http://www.infosheet.com/iScripts.html):
This script contains several additions to FormMail, including a courtesy
reply e-mail to the visitor, the ability to add fields to a flat file
database, and support for fax to e-mail services.
yForm.cgi (at http://www.fyi.net/~abass/domino/misc.htm):
This modification lets you specify whether or not you wish to send the
courtesy reply and whether or not you wish to log all form submissions
in a database file located on your sever.
BNBForm.cgi (at http://bignosebird.com/carchive/bnbform.shtml):
Provides the capability to mix and match features such as e-mail to you,
autorespond to submitter, and write to data file.
The following scripts have additional features:
AlienForm (at http://cgi.tj/scripts/alienform/):
Easy to use Form to Email gateway; uses simple templates to format all
aspects of its output. Can send out more than one email at once, and can
write directly to files, allowing you to log every time the form is submitted.
It does not have to send email on every invocation: so you can have multi-part
forms which only send email (or write to a file) on the last stage. It
can perform mathematical calculations on the data supplied and validate
the form.
Soupermail (at http://soupermail.sourceforge.net/)
A very powerful form processing script (although relatively more difficult
to configure) provides the most extensive set of features, including database
generation, multi-page forms, mathematical operations and more.
If you do not have CGI capability on your server,
some web sites will host the CGI script for you remotely (see below).
But, as you might expect, that will come at a price. Web sites that offer
"free" remote hosting of CGI scripts are likely to either use
banner ads or load a page from their site on the users' browser after
the form has been processed. Even so, if you do not have CGI capability,
that may be worth your while. Here are some sites that offer "free"
remotely-hosted CGI scripts for processing forms:
http://www.freedback.com/
http://www.dk3.com/dk3page.pl?id=formmail
http://www.response-o-matic.com/
For more sites such as the two above, which provide "remotely-hosted"
form handling, and for many related scripts, please see:
http://cgi.resourceindex.com/Remotely_Hosted/Form_Processing/
|