Form Submission
A user enters input into the fields
of a form. When the form is submitted, the data contained in each
field of the form is transferred to the server, which then passes it
to ASP. This data is sent in the format
name
=value
, where name
is the name
assigned to the field by the NAME=
attribute of
the <INPUT>
tag, and
value
is the value entered in that field.
For example, if the user enters "Archie" in a field
prompting for his first name, the browser may send along the string
first_name=Archie
.
If the form is written to use
METHOD=GET
, the form data is appended to the
URL as an argument string. If the form contains many fields or if
fields contain long strings of text, the complete URL can become very
large and unwieldy. In addition, the limit of the number of
characters submitted in a GET
—typically
about 2000—is much lower than in a POST
.
If the form instead uses METHOD=POST
, the
name
=value
pairs are sent as the body of the request
instead of being appended to the URL. In addition to the greater ease
of handling of POST
requests, most servers offer
better performance when extracting data from the body of a request
than from a URL in the request header.
Always use the POST
method with forms that change
something or cause any irreversible action (most do).
POST
is safer and more efficient;
GET
should never be used to change anything. In
developing your ASP scripts, you can decide whether you want to
support data passed to your program using the GET
method.
Get ASP in a Nutshell, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.