1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

When to use GET or POST in php???

Discussion in 'Programming' started by gauravyadav, Oct 16, 2012.

  1. #1
    Where to use GET or POST Method in php???
     
    Last edited: Oct 16, 2012
    gauravyadav, Oct 16, 2012 IP
  2. pHrEaK

    pHrEaK Active Member

    Messages:
    147
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #2
    Google works wonders -> HERE
     
    pHrEaK, Oct 16, 2012 IP
  3. garnet2k

    garnet2k Member

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    In general - if a request dont change anything in the DB it is GET.
     
    garnet2k, Oct 17, 2012 IP
  4. allittakes

    allittakes Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I most certainly feel when you are not in a dynamic environment and security is your major concern your 1st choice should be POST Request. Rest GET takes you of out of a lot of tight spots like ajax and similar stuff that require continues requests up and down the client and server.
     
    allittakes, Oct 17, 2012 IP
  5. Wogan

    Wogan Peon

    Messages:
    81
    Likes Received:
    3
    Best Answers:
    2
    Trophy Points:
    0
    #5
    Simple formula:

    GET - Read-only content requests (Fetch)
    POST - Updating content on your server (Update)

    Mostly because POST can handle longer content-lengths and files via multipart, whereas GET requests are fully visible in the user's address bar.
     
    Wogan, Oct 17, 2012 IP
  6. ggiindia

    ggiindia Greenhorn

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #6
    Then which is mostly used in programming GET or POST?
    Also which is always better to use? please guide!
     
    ggiindia, Oct 18, 2012 IP
  7. Wogan

    Wogan Peon

    Messages:
    81
    Likes Received:
    3
    Best Answers:
    2
    Trophy Points:
    0
    #7
    There's no "always" or "better" - they're 2 different request methods with different uses. You can't use GET to upload a file for instance - and you can't use POST if you want URLs with parameters.
     
    Wogan, Oct 18, 2012 IP
  8. ggiindia

    ggiindia Greenhorn

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #8
    Okay useful for me.. Thanks Wogan:)
     
    ggiindia, Oct 19, 2012 IP
  9. MultiCoder

    MultiCoder Active Member

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #9
    Good explainasion from Wogan, i would just like to add, POST offers better privacy for the user, while GET is more secure for the server.

    If a user uploads a binary file like a picture, you will need to use POST, if the form contains private information like a persons real name, address etc. i would use POST so the data isn't in the url and can be seen by others, and i would use GET for allmost anything else, with GET a user can't upload a binary virus correctly forexample.
     
    MultiCoder, Oct 19, 2012 IP
  10. henrycarpenter03

    henrycarpenter03 Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Quite simply, If the submission is reading data, without making any changes, use GET. If your submission will be making changes, or causing side-effects, use POST. For example, when doing a query, such as a Google search, the form should use GET. If you are creating a new account with Yahoo! mail, the form should use POST. The Google search is reading data and new account in Yahoo! mail is changing things.
     
    henrycarpenter03, Oct 26, 2012 IP
  11. janecristy

    janecristy Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #11
    I use get method when i do no want to send username, passwords or logging in data. Get method can not be used to send images in php. Post method is used for it.
     
    janecristy, Oct 29, 2012 IP