HTML and CSS Reference
In-Depth Information
Watching GET in action
There's no better way to understand GET than to see it in action.
Open up your “form.html” file and make the following small change:
<form action="http://starbuzzcoffee.com/processorder.php" method=" GET ">
Save and reload the page; then fill out the form and submit it. You
should see something like this:
http://starbuzzcoffee.com/processorder.php?beans=Kenya&beantype=ground&
extras%5B%5D=catalog&name=Buckaroo+Banzai&address=Banzai+Institute&city=
Los+Angeles&state=CA&zip=90050&phone=3105551212&comments=Great+coffee
Now y ou can se e every fo rm
elemen t name a nd its val ues
right here in t he URL.
Q: Why is it called GET if we're
sending something to the server?
A: Good question. What's the main job of
a browser? To get web pages from a server.
And when you are using GET, the browser
is just going about getting a web page in the
normal way it always does, except that, in
the case of a form, it has appended some
more data to the end of the URL. Other than
that, the browser just acts like it's a normal
request.
Q: So why would I use POST over GET,
or vice versa?
A: There are a couple of big differences
that really matter. If you want users to be
able to bookmark pages that are the result
of submitting a form, then you have to use
GET, because there is no way to bookmark
a page that has been returned as a result of
a POST. When would you want to do that?
Say you have a server script that returns a
list of search results; you might want users
to be able to bookmark those results so they
can see them again without having to fill out
a form.
wouldn't want users to be able to bookmark
the page. (Otherwise, every time they
returned to the bookmark, the order would
be resubmitted.)
A situation when you'd never want to use
a GET is when the data in your form is
private, like a credit card or a password.
Because the URL is in plain view, the private
information is easily found by others if they
look through your browser history or if the
GET somehow gets bookmarked.
Finally, if you use a <textarea>, you should
use POST, because you're probably sending
a lot of data. Both GET and POST requests
have a limit on the amount of data you can
send, but the limit on a POST request is
usually much larger.
With POST, on the other hand, the browser
actually creates a little data package and
sends it to the server.
On the other hand, if you have a server
script that processes orders, then you
 
Search WWH ::




Custom Search