HTML and CSS Reference
In-Depth Information
the URL back to the user—may also wish to make a point of stripping off the old query string.
Replacing Forms with Links
The really big advantage of switching from POST to GET is that you no longer need to use forms at all. You can
still use forms if you like, but you can also create static links that make particular queries. For example,
consider the article list form from the beginning of this section. You can now make a link that finds the ten most
recent articles:
<a href="article.php?sort=Reverse&amp;number=10">
10 Most Recent Articles
Or you can make a link to the very first article:
<a href="article.php?sort=Forward&amp;number=1">
The one that started it all
Furthermore, not only can you make links such as these, but other people who want to link to your site can mint
these URLs, too. They can bookmark your pages and use these URLs in several other ways to drive traffic to
you. None of that is possible with POST.
Of course, any such links you write must be properly encoded both according to XHTML's rules and according to
URL rules. For XHTML, this means you must encode each & as amp; . Thus, a URL such as /article.php?
sort=Reverse&number=10 is typed in the XHTML document as /article.php?sort=Reverse&amp;number=10.
URLs further require that all non-ASCII characters as well as the space, the forward slash, the colon, the equals
sign, and other nonalphanumeric characters that have special meaning in URLs be percent-encoded. For ASCII
characters, this just means replacing the character with a percent sign followed by the hexadecimal value of the
character. For example, the space is ASCII 32 in decimal and 20 in hex. Therefore, spaces encoded in your URLs
are encoded as %20 . The colon is ASCII character 58 in decimal and 3E in hex. Therefore, colons included in
your query strings are encoded as %3E . Non-ASCII characters are first converted to individual UTF-8 bytes. Then
each byte is percent-encoded.
This is the same encoding used by a browser before it submits a form to the server. One way to figure out the
strings you need is simply to create a form that builds them, submit it, and copy the resulting URL out of the
browser's location bar.
Search WWH ::

Custom Search