The Basic Form (<form>)
The <form>
tag, which is used to designate a
form, contains the information necessary for interacting with a
program on the server. A form is made up of a number of controls
(checkboxes, menus, text-entry fields, buttons, etc.) used for
entering information. When the user has completed the form and
presses the “submit” button, the browser takes the
information, arranges it into name/value pairs, encodes the
information for transfer, and then sends it off to the server.
You can have several forms within a single document, but they cannot
be nested, and you must be careful they do not overlap. Figure 15-1 shows a very simple form and its
<form> tag.

Figure 15-1. A simple form
The action Attribute
The
action attribute in the
<form> tag provides the URL of the program
to be used for processing the form. In the example in Figure 15-1, the form information is going to a Perl
script called guestbook.pl, which resides in
the cgi-bin directory of the current server (by
convention, CGI programs are usually kept in a directory called
cgi-bin).
The method Attribute
The method
attribute
specifies one of two methods, either
get
or post, by which the
information from the form can be transmitted to the server. Form
information is typically transferred in a series of
name=value pairs, separated by the
ampersand (&)
character.
Let’s take into consideration a simple form with ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access