| HTML
forms can be used to obtain information and feedback from people who visit your Web site.
Guest Book is one example of popular forms that is used almost on any personal Web site.
There are two major steps in processing data from visitors: 1. First, create a form to obtain desired data from visitors.
2. Second, write a script to process data from the form. A
script is a program written in particular computer language, such as in Perl and C
languages. The output from such that script is delivered to you by e-mail or stored in a
database or a text file, for example.
In this article, we will walk you through the steps in
creating an HTML form. We begin first with detailed explanation about some useful HTML
form tags and examples.
1. Some Useful Form's Tags
a)<FORM></FORM>
This pair of tags begins and ends any form definition. Other form elements are contained
within this pair of tags. There are two important attributes that go between the
<FORM> tag:
- The METHOD attribute specifies how the data will be
processed by the form scripts. Normally, the value assigned to this METHOD is either
"post" or "get" depending on the method of data processing. Method
"post" is commonly used.
- The ACTION attribute specifies the location of the script
that processes the form.
Example: <FORM METHOD="post"
ACTION="/cgi-bin/form.pl">
The attribute ACTION points
to the Perl script naned "form.pl" and this script is located in the directory
cgi-bin.
b)
<INPUT>: This tag is used to create many types of
input, such as single lines of text, radio buttons, check boxes, and the button to submit
or clear the form. Some important attributes and their values:
- TYPE attribute determines the type of input field you want o
display. For example, it can be text, radio button, check boxes, etc. Example:
TYPE="text", TYPE="password"
- NAME attribute assigns a name to this input field. Because
we can create as many input fields in the form as we want to, so it's required that you
have to assign a name to each input field, except the Submit and Clear buttons(optional).
- SIZE attribute specifies the number of characters that a
visitor can type the input field.
- MAXLENGTH attribute specifies the maximun number of
characters that ca nbe entered into this input field.
- VALUE attribute specifies the default value for this input.
- CHECKED attribute sets the checked mark on the radio button
and the check box.
Example: To
create an input field that accept password from visitors.
<INPUT TYPE="password" NAME="secret_word" SIZE="30"
MAXLENGTH="30">
|