• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 233
  • Last Modified:

Get and Post

I remember seeing somewhere a brief, if somewhat simplified explanation of which method was best in which situation. I've looked on a lot of faq sites, but can't find anywhere that contrasts the two. Could anyone fill me in?
Cheers
0
AndrewThomason
Asked:
AndrewThomason
1 Solution
 
brunovanCommented:
use post to send it as input to a script, and use get to send it to a file.

Bruno
0
 
AndrewThomasonAuthor Commented:
To brief
0
 
evilgregCommented:
Short answer:
GET is quick and efficient, but very limited.
POST is a little harder to implement, but more secure (and nice looking) and handles more data.

(This isn't really a perl question, per se, but...)

GET advantages:
- It's short and quick
- You can see all the data that is going to be submitted.
- It can be put into a link, and no FORM tags are necessary.
- It's real easy to change the input, especially when testing a new form

GET disadvantages:
- All the data is world viewable (see any search engine for an example)
- It can form really long, ugly URL's
- It severly limits the amount of data that can be sent

POST advantages:
- Data is not world viewable
- Short, sweet URLs. The same URL can do many different things.
- Send as much data as you want

POST disadvantages:
- Harder to debug your apps (although this is easy to get around)
- Harder to code for the client (HTML) and for the server (cgi)

Generally, GET should be used for short, quick inquiries (again, see the search engines). For more than a few fields or a few lines of data, use POST.

Because GET data gets shoved into an environment variable (QUERY_INFO), it has a finite limit on how much data can be sent it. It's a lot, but I find it personally "cleaner" to just use POST most of the time, in which the data becomes stdin and can hold as much as you want.

Some good times to use GET:
Search forms
Simple redirects

Some good times to use POST:
Long user input forms
Sending data between forms
Hiding previous data cleanly with the INPUT TYPE=HIDDEN tag.

A final caveat, it really does depend on the exact situation: the amount of data, how comfortable you are with each type, how important speed is, how important "nice looking" URLs are, etc...

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now