p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: GET and POST


Message #1 by "Rodrigo Penloski - Som Livre.com" <Rodrigo@s...> on Wed, 30 Oct 2002 10:38:20 -0300
What is the difference? What should I use?
I see that when you use POST and $_POST['somevar'] the pair of
'variable=3Dvalue', is not shown on the URL... is this it?

TIA

penkz
Message #2 by "Nikolai Devereaux" <yomama@u...> on Wed, 30 Oct 2002 10:28:02 -0800
POST and GET are two different methods of sending key/value pairs (variable
names and their values) from the client to the server.

Any variables passed on the URL are GET parameters.  HTML forms which set their
method to GET rely on the browser to construct the URL with the key/value pairs
in place.

HTML forms which set their method to POST send their key/value pairs in the
HTTP headers, not in the URL.

The only major differences between the two are

1) you're restricted somewhat when using GET because there is a length
restriction on the URL string.  (phpMyAdmin falls victim to this, or at least
the version I'm running does.)

2) POST doesn't clutter the URL string the way GET does

3) Your browser won't complain when going back to a page that you submitted GET
data to, since all the data is already in the URL you're going back to.  If you
go back to a page you POSTed data to, your browser will pop up a warning saying
that the page won't be displayed properly unless you resubmit the form data.


Whether you choose GET or POST is really up to you.  Play around with each of
them and figure out which you prefer is all I can say.  You don't have to set
all your forms one way or the other -- feel free to mix them up if it's
appropriate.  Just make sure you're looking in the right place on the other end
for the submitted data!


take care,

nik


  Return to Index