In general, you need a CGI script (or, more generally, some server-side tool) in order to use HTML forms efficiently. Primarily you should consult your Internet service provider or the local webmaster about the availability of local scripts which you can use. This document discusses what you can do if that primary approach is not feasible for some reason.
Writing CGI scripts requires more knowledge about programming than most HTML authors are willing to know or need to know. Moreover, several Web server maintainers have strict policy as regards to CGI scripts. Therefore, you may wish to consider using a CGI on a remote server. There are some services which allow you to use CGI scripts on their site, usually for some fee, but there are also free services.
The The CGI Resource Index contains a large list of such services: Programs and Scripts: Remotely Hosted: Form Processing. It will probably be maintained better than this document, which will only attempt to describe and illustrate the use of a few services.
Warning: Of course anyone offering a service for free has the right to discontinue the free service at any time. That's what happened e.g. to the FreeStuff service which was previously used on this page! (It has been replaced by Free&Clear, which is a rather different service.) Moreover, free services are often funded by advertisements, so if you use them, some ads may get sent along with the form data and/or displayed to the user after he has submitted a form. The free services might serve your purposes if you need them for a limited time only or you are willing to find a new service every now and then.
Similarly, the nice FlashBase Forms service was discontinued 2001-02-12. The announcement about this suggested trying ActiveSpace, BitLocker and FormSite as providing similar services.
Typically, but not necessarily, the services discussed here can be used as follows:
ACTION
attribute of
the FORM
element. It should also tell you
which form fields you must set and which
you may additionally set.
For example, the name of the field which will be used by the
service to determine to which E-mail address the data is
to be sent might be
To
or recipient
or something else.
Check the documentation of the service you are about to use.
It is safest to use the exact spelling for the field names
as given in the documentation; the names can be
case-sensitive!
INPUT TYPE="HIDDEN"
(for example,
<INPUT TYPE="HIDDEN" NAME="To"
VALUE="youraddress">
) or
you can include a normal text input field to let the the user fill
it out. The former is typically used for recipient address(es),
the latter for the real input you want from the user. An
intermediate method is also possible: you can use a prefilled
text input field like
<INPUT TYPE="TEXT" NAME="Subject"
VALUE="Comments on your document on perpetuum mobile">
.
The user can then leave that field untouched or edit it.
(Warning: This is an example only. Some services may use a field
named Subject
as the Subject
line of an
E-mail message in which they send the form data. Some -
probably
most - don't.)
Note: These services often carry identical or very similar names, in spite of being quite different and distinct. When using a service, make sure you are consulting its documentation!
The following example uses
TipJar's free
generic form handler.
It is written especially to illustrate how an author of a Web
page can construct a convenient simple feedback form.
Many authors think that telling the E-mail address
(and making it a
mailto
link)
for feedback is not sufficient,
since people send them feedback without telling which page it
relates to! So the authors would like to
set a Subject
header
for an mailto
link.
WDG's
Web Authoring FAQ explains
why there is no reliable way to do that,
and suggests using a form instead.
And here's an example:
HTML markup:
<form action="http://www.tipjar.com/cgi-bin/generic"
method="post">
<p>
<input type="hidden" name="mailto" value="jukkakk@gmail.com">
<input type="hidden" name="subject" value="Comments on forminfo">
Please type your contribution:<br>
<textarea name="mail" rows="8" cols="50">
My comments on "Information about services for using HTML forms":
</textarea>
<br>
Sender's E-mail address (optional):
<input type="text" name="mailfrom" size="30">
<br>
<input type="submit" value="Send">
</p>
</form>
Explanations:
mailto
. In this case, we want this
address to be fixed, so we use a
hidden field (input type="hidden"
)
for it.
subject
can be used to set
the Subject
header in the E-mail message. We use this
possibility, to let the recipient see directly from that
line what the message relates to.
textarea
field. The user is assumed to
type his message after the prefilled content.
mailfrom
and put it into the From
header of the E-mail
message. This implies that (if the address is correct)
the recipient can conveniently use the reply function
of his E-mail program.
This looks like the following on your current browser (notice that the presentation can be affected by style sheets):
Note: It is advisable to include your E-mail address visibly into the page even if you set up a feedback form. People may have their reasons not to use your form. (For example, I prefer sending E-mail using my favorite E-mail program which keeps a nice archive of sent mail and which I know well.)
This example as such is obsolete, since the service it used has been removed. I've preserved it to illustrate an idea, though.
The following simple example illustrates a somewhat untypical use
of a typical service.
It uses
D3 FormMail
which comes with simple instructions.
That particular service
requires only one form field to be set,
namely a field named TO
, and it sends the
form data to the E-mail address specified in that field.
It allows some other form fields to be set,
such as a field determining the Subject
header,
a field for the sender's E-mail address (if the sender wishes
to write it), and a field specifying the "thank you" page address.
Fields without predefined meaning are just passed along with
the form data, so you can use whatever names you like for the real
input from the user, if you just avoid the predefined names:
TO
, subject
, EMAIL
,
and SENTPAGE
.
Our example is untypical only in the sense that the recipient address is not specified in a hidden field but to be written by the user. This lets you test how such forms work: type your address into the Recipient field, and you'll get an E-mail message containing the form data.
<FORM METHOD="POST" ACTION="http://d-eyes.jpte.hu/~dave/formmail.cgi"> <P> Recipient:<INPUT TYPE="TEXT" NAME="TO"><BR> Your input: <INPUT TYPE="TEXT" NAME="data" SIZE="40"> <INPUT TYPE="HIDDEN" NAME="SENTPAGE" VALUE= "../HTML3.2/thx.html"> <INPUT TYPE="SUBMIT" VALUE="Send"> </P> </FORM>
On your current browser, this looks like the following:
The use of the following services will be illustrated here (because they were the ones that were known to the author when he wrote the first version of this document). Only the forms themselves as displayed by your browser are shown here; please use the "View source" function of your browser to see the HTML codes.
Notice that they send the information to the author of this document, not to you, so that by using these as such you will only see a demonstration of what things might look to the user.
These are just examples. Please consult Programs and Scripts: Remotely Hosted: Form Processing in The CGI Resource Index for a much larger (annotated) list.
Other free services:
Commercial services:
Last update: 2001-12-07.