More advanced HTML features:
Form Handler
We have created a way for users at Lehigh to use their own forms (The Intermediate
Web Authoring seminar includes detailed instructions on creating web
based forms). Forms are HTML documents which allow you to obtain information
from users browsing through your home pages. The comment
form and guestbook
documents available to Lehigh home page owners are two examples of how
forms can be used. We also make available a script to handle processing
of 'generic' forms, so that users can write their own forms and have the
input emailed to them.
This documentation explains the forms handler:
-
Technical Details: for those who already
know how to create a form, this gives the technical specs for creating
a form to use the form handler
-
How to do it: for those who are creating
their first form, this gives instructions in more detail.
-
What happens: what the output of the form
will be.
-
Example Form: An example of the whole form.
Detailed documentation
by the author of the form processing script is also available.
Technical Details
When an HTML form document is used, there is an ACTION specified
that tells Lehigh's server what to do with the information provided in
a form, and there is also a METHOD specified which controls how
the information is sent to Lehigh's server. Ordinarily, the ACTION
specifies that some program be run on the server that processes the data
received. These programs are called CGI scripts. Users can't write CGI
scripts for Lehigh's server, so we have written a generic script which
will process form data.
This CGI script accepts form input from most HTML forms. Certain restrictions
apply: the method must be POST, INPUT/FILE fields are not supported, and
certain fields (FORMNAME, RECIPIENT, and SENDER--the names are case-sensitive)
are required. Another special field (CO-RECIPIENT) is optional. RECIPIENT,
CO-RECIPIENT, and SENDER are electronic mail addresses. RECIPIENT, CO-RECIPIENT,
and FORMNAME are usually specified as "hidden" fields. SENDER is usually
a field of type INPUT/TEXT for an address supplied by the person filling
out the form. The contents of the form are sent to the address specified
as RECIPIENT as an e-mail message. The message appears as if it were from
the SENDER.
-
METHOD="POST"
-
ACTION="http://www.lehigh.edu/cgi-bin/pquery"
-
<INPUT TYPE="hidden" NAME="FORMNAME" VALUE="Name of Form">
(The VALUE will be the subject line of the email containing
the form contents)
-
<INPUT TYPE="hidden" NAME="RECIPIENT" VALUE="Your Email Address">
(The VALUE of this field must be the full email address
to which the form contents should be sent.)
-
<INPUT TYPE="text" NAME="SENDER">
(The VALUE entered into this field must be a full, valid
email address. This should be the person completing the form; the email
of the form contents appears to come from this address)
-
A single additional recipient can be added by adding a field for CO-RECIPIENT:
<INPUT TYPE="hidden" NAME="CO-RECIPIENT" VALUE="Email Address">
The forms handler includes support for author-defined required
fields. Any field (for example, a field named "x") can be immediately
preceeded by a field named "x-REQUIRED" (caps mandatory) which indicates
that the following field is "required" (i.e., must not be blank). If a
required field is left blank, the form is rejected. The "x-REQUIRED" field
is normally specified as a "hidden" field. Any value given to this "x-REQUIRED"
field is ignored.
NAMEs of fields should not have spaces, etc. in them; names with spaces
will be truncated at the first space.
Note: the current form handler, pquery, replaces an older form handler
script, process_query. process_query can cause submission errors and is
no longer supported. Most forms can be converted to pquery without a problem,
but you should verify that the old form has RECIPIENT, FORMNAME, and SENDER
fields and that RECIPIENT and SENDER addresses are full email addresses.
Instructions: Creating a Form to use the Form
Handler
The data processed by Lehigh's generic form handler will be sent as an
e-mail message to the form owner. The following instructions describe how
to use the form handler to process data entered into a form that you create.
There are 3 steps you need to perform in creating a form ...
-
Create a form with the correct ACTION and METHOD specified
-
Add mandatory fields (make sure the field names are upper case)
-
Upload the form to the web and link to it from an existing HTML document
Step 1: Create a form
This CGI script accepts form input from most HTML forms. Certain restrictions
apply: the method must be POST, INPUT/FILE fields are not supported, and
certain fields (FORMNAME, RECIPIENT, and SENDER--the names are case-sensitive)
are required. Another special field (CO-RECIPIENT) is optional.
This section includes some basic information about creating fields in
forms. You may want to consult the Advanced
web authoring forms documentation. In addition, most guides to web
page creation include information on creating forms; you will probably
want to read up on them before beginning.
You will need to create an HTML document, putting the form elements inside
it. (Note: Netscape Composer does not support forms creation. Handcoding
HTML, or using HTML tools such as Dreamweaver and VisualPage is suggested
for creating HTML forms. Frontpage is not recommended for form creation
at this time.)
Begin the form by putting in the following FORM tag:
<FORM METHOD="POST" ACTION="http://www.lehigh.edu/cgi-bin/pquery">
Be sure to end the form element with the following tag:
</FORM>
Form Field Elements
INPUT, TEXTAREA, SELECT, etc. elements should be added within the form
element (between the two tags) along with appropriate text, to create the
form you want. Each input field element must has a NAME and a VALUE is
either defined for the element or entered into it.