...

View Full Version : POST vs GET



NancyJ
01-05-2006, 09:51 AM
IMO, theres really no advantage in using GET to handle form data, but I noticed a lot of big sites like google and amazon etc use the querystring to pass data between pages, I was just wondering if anyone had any insight into why they do that?

marek_mar
01-05-2006, 10:45 AM
The URL with the querystring can be copied and pasted.

hemebond
01-05-2006, 10:46 AM
Because GET it for retrieving resources/documents etc. It is considered safe and should not modify any data. POST is for updating/manipulating data.

NancyJ
01-05-2006, 10:50 AM
Because GET it for retrieving resources/documents etc. It is considered safe and should not modify any data. POST is for updating/manipulating data.
Thats not a reason, querystrings are ugly and I avoid them whenever possible, just because querying data is considered safe doesnt mean you should use GET, it just means that no harm should come of using it. I can however see marek_mar's point about being able to copy the full url.
The new site I'm working on uses querystring, when I asked why the guy said cos at the time he didnt know any better way of doing it, then later they decided to keep it because it looked 'techy' :eek:

hemebond
01-05-2006, 10:56 AM
Thats not a reason, querystrings are ugly and I avoid them whenever possible, just because querying data is considered safe doesnt mean you should use GETOf course you should. That's how the web works. That's what it's for. Using POST requests to retrieve data is stupid and wrong. It goes against well though-out web fundamentals.

If you want to make clean URL's, use server-side redirection so the user can accept 'nice' URI's.

NancyJ
01-05-2006, 11:20 AM
Using POST requests to retrieve data is stupid and wrong.
Care to back that up?

There are many times when you would never use a GET to query the database - just one example - login. That does not manipulate data, it only queries the database to find the user but you wouldnt use a GET for that - or would you?

hemebond
01-05-2006, 11:34 AM
Care to back that up?Ever tried to use Firefox's "Add a Keyword for this Search" function with forms that use POST?
There are many times when you would never use a GET to query the database - just one example - login. That does not manipulate data, it only queries the database to find the user but you wouldnt use a GET for that - or would you?You are submitting information to the server. You are sending your credentials. You are modifying data, because you are initiating authorisation. POST should not return anything. After submitting your login details, you should be redirected with a GET request for a new resource (otherwise the user would just see a blank page after logging in).

Read http://www.w3.org/2001/tag/doc/whenToUseGet.html and http://www.cs.tut.fi/~jkorpela/forms/methods.html , they explain things better than I ever could.

NancyJ
01-05-2006, 11:52 AM
The first document basically just says the only reason to prefer GET over POST is for bookmarking/linking/caching as already mentioned.
The second documents says you should use GET over post for queries just because W3C say so, it also says they give no reason for it, it later goes on to why the specification rules dont work in the 'real world' and there are times when you would have to break the rules either way - eg non ASCII characters possible in input, long query strings, hidden fields.

So none of that backs up the 'Using POST requests to retrieve data is stupid and wrong.'.

hemebond
01-05-2006, 11:57 AM
The second documents says you should use GET over post for queries just because W3C say so, it also says they give no reason for itYou're right. What would the W3C know about the web.

Tell you what. You use whatever method you want to, and I'll look the other way.

NancyJ
01-05-2006, 12:20 PM
You're right. What would the W3C know about the web.

Tell you what. You use whatever method you want to, and I'll look the other way.
Well you and the other sheep can follow any orders you like without any explaination or reasoning, but I'm one of those people who has a brain and can think for myself.
Just some food for thought, the W3C break their own rules (and admit to it) with their validator and fully admit that blindly following these rules doesnt work in the real world. There are plenty reasons why you would want/need to use post for queries.

hemebond
01-05-2006, 12:24 PM
Well you and the other sheep can follow any orders you like without any explaination or reasoning, but I'm one of those people who has a brain and can think for myself.We do have reasons. And the key to standards is that everyone agrees to follow them. That's why the web has worked as well as it has. You don't want to play? Go make your own sand-pit.

Can you give me a good reason to not follow these rules?

NancyJ
01-05-2006, 01:43 PM
We do have reasons.
You've still not provided any. Only an idiot would obey a rule blindly without question, just because someone else said so.


And the key to standards is that everyone agrees to follow them. That's why the web has worked as well as it has.
Thats a load of crap.
Most people dont follow the standards, in fact most people dont even know they exist. The web isnt somewhere where you have to read a rule book and pass a test or agree to terms and conditions before you can make and publish a website. Anyone with a computer can call themselves a 'web designer' and start putting crap out on the web.
The W3C have nothing to do with the success of the web. Look at their 'achievements'
October 1996: PNG Recommendation - still not widely used, with gifs and jpgs being prefered for web.
December 1996: CSS 1.0 - still not fully supported by mainstream browsers
Feb 1997: WAI - sites that comply are still in the minority

Dont get me wrong, I'm all for web standards, but you cannot say that they are why the web works, because it just isnt the case.
The affect they have on the web is minimal. If that changes, great, if it doesnt, the majority of people wont even notice, or care.



Can you give me a good reason to not follow these rules?
I have, twice.

firepages
01-05-2006, 04:46 PM
Only post here if you have a new answer/idea re: the original question.

Any more bickering and I will set the Spookster on you..

missing-score
01-05-2006, 06:03 PM
POST vs GET:

POST can send very large amounts of data and file uploads, whereas GET is usually limited to 1 KB. Sensitive information can be sent through POST becuase it does not appear in the brower address bar.

GET vs POST:

URLs ith a querystring can be easily bookmarked by a user, for example google search results. The URL can be copy/pasted and give the same outcome. GET is also very important for people who dont have cookies on a site using PHP sessions. Finally, GET variables can be added to basic links (<a href="..">) and not just in forms (which is required to send POST information).


IMHO:

GET is a much better method to use when making requests for data, providing it is used properly. Using GET means copiable URLS and also that implementing .htaccess rewrite rules to access specific pages is very easy. Also (although I'm not sure of the exact rules search engines use), it means that your URL's might be indexed better due to querystring information.

GJay
01-05-2006, 06:33 PM
It's probably worth noting that while for operations that don't modify things, it's pretty irrelevant which method you use (in most cases...), the opposite isn't true. Using GET for modification is in the majority of cases isn't particularly sensible, for precisely the reason that it can be bookmarked, navigated back to/refreshed (without a friendly browser warning). While this is probably ok for a script that only you will run (it would, for example be easier to run from a command-line should you so desire), if there's end-users involved then it becomes unintuitive.

VBAssassin
01-05-2006, 09:46 PM
Wew this got a lot of responses!

GET:

Best Used
Best used if it changes the page in some way to the public, this way search engines can go to the link and save that page as a page of its own (with the get string changing making hundreds of pages on your site)... its also good if someone wants to copy a link to someone to go to that specific page.

Example
Imaging if you wanted to send this forum topic to someone, but all it was was "topic.php"

having the "topic.php?topic=1" takes you to the correct topic in the forum ;-)

POST:

Best Used
Best used for everything else! Especially data you dont want modifying as its not so easy to change as a get string is.

Best Regards,
scott



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum