HTML and CSS Reference
In-Depth Information
Although most forms send their data to scripts, you also can make the action link to
another web page or a
mailto
link. The latter is formed as follows:
<form action=“mailto:somebody@isp.com” method=“post”>
This attaches the form data set to an email, which then is sent to the email address listed
in the
action
attribute.
TIP
To test your forms, I recommend using the
get
method and leav-
ing out the
action
attribute of the form tag. When you submit the
form, the values you entered will appear in the URL for the page
so that you can inspect them and make sure that the results are
what you expected.
The
method
attribute supports two values:
get
or
post
. The method indicates how the
form data should be packaged in the request that's sent back to the server. The
get
method appends the form data to the URL in the request. The form data is separated
from the URL in the request by a question mark and is referred to as the
query string
. If
I have a text input field named
searchstring
and enter
Orangutans
in the field, the
resulting would look like the following:
11
The
method
attribute is not required; if you leave it out, the
get
method will be used. The
other method is
post
. Instead of appending the form data to the URL and sending the
combined URL-data string to the server,
post
sends the form data to the location speci-
fied by the
action
attribute in the body of the request.
DO
DON'T
DO use the
POST
method when data on
the server will be changed in any way.
DO use the
GET
method if the form just
requests data like search forms, for
example.
DO use the
GET
method if you want to
bookmark the results of the form
submission.
DON'T use the
GET
method if you do
not want the form parameters to be
visible in a URL.
DON'T use the
GET
method if the form
is used to delete information.


