when the heck do i use GET and POST?

Discussion in 'PHP' started by whiteblue1942, Mar 7, 2008.

  1. #1
    ok can someone PLEASE explain to me what the heck the difference between using GET and POST is in form submission in PHP except that u can bookmark pages and that the information shows up in the browser bar. Besides that they seem completely the same to me!
     
    whiteblue1942, Mar 7, 2008 IP
  2. milesbparty

    milesbparty Peon

    Messages:
    148
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    GET and POST are independent of PHP, and are specifications for HTTP methods.

    Instead of me just regurgitating information, it would probably be more worthwhile for you to read it yourself:

    http://www.w3.org/2001/tag/doc/whenToUseGet.html
     
    milesbparty, Mar 7, 2008 IP
  3. whiteblue1942

    whiteblue1942 Peon

    Messages:
    573
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    0
    #3
    yea i dont understand any of that
     
    whiteblue1942, Mar 7, 2008 IP
  4. milesbparty

    milesbparty Peon

    Messages:
    148
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Basically, as you pointed out, GET passes data to the resource on the URI, and POST passes data in the body of the request.

    Use GET for operations that don't change the state of the server; only for information retrieval (queries).

    Use POST when the request will modify a resource on the server.

    Sorry if this doesn't really clear things up. I really think it would be worthwhile for you to read some of the documentation and get a good feel for the different situations to use either GET or POST.
     
    milesbparty, Mar 7, 2008 IP
  5. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #5
    Use POST if the information is private or large. Else use GET. Don't send passwords via GET. Don't send War & Peace via GET. Plus don't crowd the address bar with 62 variables. Got it?
     
    shallowink, Mar 7, 2008 IP
  6. milesbparty

    milesbparty Peon

    Messages:
    148
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks. Good points. I was having a difficult time explaining...

    Ah, and to expand on shallowink's comments, GET *does* have a limit on the number of characters that can be passed on the URI (can't remember off the top of my head), so for large amounts of data being passed, you MUST use POST.
     
    milesbparty, Mar 7, 2008 IP
  7. whiteblue1942

    whiteblue1942 Peon

    Messages:
    573
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    0
    #7
    why dont i just alwayse use post then?
     
    whiteblue1942, Mar 7, 2008 IP
  8. blueparukia

    blueparukia Well-Known Member

    Messages:
    1,564
    Likes Received:
    71
    Best Answers:
    7
    Trophy Points:
    160
    #8
    You can if you wish. I always use post...
     
    blueparukia, Mar 7, 2008 IP
  9. Lordy

    Lordy Peon

    Messages:
    1,643
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    0
    #9
    sometimes you may want to have the user be able to change the URL without actually having to submit the whole form again
     
    Lordy, Mar 8, 2008 IP
  10. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #10
    You will learn to use GET while debugging.
     
    shallowink, Mar 8, 2008 IP