homepage Welcome to WebmasterWorld Guest from 54.196.196.108
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

    
Is GET/POST totally interchangeable?
new to web programming
fordkcar




msg:572362
 4:23 pm on Nov 29, 2001 (gmt 0)

I've been given the assignment of maintaining a web application that consists of forms submitted to the server to be archived. The problem is users are putting in too much data into the comment areas (<textarea>) and the GET can't handle them. If I change the GET to POST will I have to change the implementation of the rest of the form?

 

Everyman




msg:572363
 4:59 pm on Nov 29, 2001 (gmt 0)

You have to change the server script that handles the information submitted in the form.

Both methods are fetched from the script's environment table, but GET ends up in the QUERY_STRING variable, while POST is fetched from stdin (standard input) after determining the content length.

Any book on CGI will explain this.

Another difference is that GET, since it is part of the URL, ends up in the server logs. POST data does not make it into the server logs, and provides extra security for that reason.

gethan




msg:572364
 4:59 pm on Nov 29, 2001 (gmt 0)

It is down to the applications* listed in the action. Most commercial or prewritten apps will be fine. So just change the method to post on an non live html page and test the results. Modify the live one when your sure.

Welcome to wmw

* as a rule php, asp, and Perl using CGI.pm is fine. Some Perl apps will be written to parse _only_ the query string to get the variables - these would break.

tedster




msg:572365
 5:04 pm on Nov 29, 2001 (gmt 0)

Welcome to Webmaster World, fordkcar.

Yes, it all depends on how the server-side routines are written. Because the two methods [GET and POST] will encode the data differently, the server needs to retrieve it differently -- so you may need to change the server-side scripting.

However, as gethan mentioned, the subroutines on your server may have already take that into account and you won't need to change anything.

I'd say test it, and if you run into trouble, the folks in our Server-side Scripting forum will be here to help.

Xoc




msg:572366
 11:10 pm on Nov 29, 2001 (gmt 0)

GET is sent as part of the URL; the part after the question mark called the query string.

POST is not sent as part of the URL. Instead it is sent in the HTTP header for the request for the new page.

GET and POST are used in different contexts. For example, if your end user bookmarks a GET page, they will also have the querystring info in their bookmark. POST pages won't bookmark the sent data. A querystring also shows up in the history list.

This has advantages and disadvantages. For example, if you use GET to send the info, and it contains a username and password, someone could look at the history list and retrieve them. If you use POST, they can't. There are also limits on how much info you can put into a querystring. There are almost no limits on a HTTP header.

Woz




msg:572367
 11:21 pm on Nov 29, 2001 (gmt 0)

Another pro for using GET with non-sestive data is that since variables end up in the URL, you can end up with multiple listings in Google.

ie., something.asp?page=2, something.asp?page=3, something.asp?page=4 and so on which can prove rather advantagous.

Onya
Woz

charlie




msg:572368
 3:19 pm on Dec 3, 2001 (gmt 0)

"get" encode data in the url, "post" in the header...

the biggest difference : you can "post" more data than you can "get"

sorry : poor english skill mode activated :)

(edited by: charlie at 4:24 pm (gmt) on Dec. 3, 2001)

joshie76




msg:572369
 4:20 pm on Dec 3, 2001 (gmt 0)

One of the advantages of using the GET method, and an important one at that, is the ability of the page to be cached. Useful if people are likely to be using the back and forward buttons through 'action' pages that receive data:

In the case of a POST method they'll get an ugly warning saying that the data's expired and they'll need to refresh before seeing anything. This also means another round trip to the server.

In the case of GET they'll pop back through the history without a nasty warning or (in most cases) a trip to the server. Ideal for passing search strings etc (which is how nearly all the SEs do it) so that people can back n' forth through the pages.

As always it's a case of picking the right tool for the right job.

Just a side note -- whilst POST data doesn't always make it into the logs, by no means does this make it secure. If you need solid security look into the https protocol

Brett_Tabke




msg:572370
 3:40 pm on Dec 15, 2001 (gmt 0)

Bears repeating because it gets over shadowed by other issues in most Get vs Post discussions:
Another difference is that GET, since it is part of the URL, ends up in the server logs. POST data does not make it into the server logs, and provides extra security for that reason.

On a different issue:

One of the advantages of using the GET method, and an important one at that, is the ability of the page to be cached. Useful if people are likely to be using the back and forward buttons through 'action' pages that receive data:

That all depends upon the browser Joshie. According to the [url=ftp.isi.edu/in-notes/rfc2616.txt]HTTP 1.1 specification[/url] section 13.9, Get's are NOT to be considered fresh unless they contain an Expires header. In otherwords, IE and Netscape are wrong.

Additionally, the forward and backward behavior of a browser is also browser independent. Some browsers will "memory cache" forward and backward get/post data - others will not.

Both issues are extremely heated. Some want to string up Berners Lee in the public square for section 13.9 paragraph 2. It's absolutely backwards of what is needed. There is a quiet war going on over it in browser circles. Moz refuses to support the spec on Get's, but Opera is obeying it. What sucks, is neither are considering what is best for users or websites. The only thing they should be doing is cache the stuff unless it is told specifically not too.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved