diffrenc betweeen get nd post method

Discussion in 'PHP' started by salikkhan, Apr 11, 2011.

  1. #1
    I am very much confused in the use of get and post method. Can anyone tell me when to use get and when o use post method. also, is there any character limit in any of them?
     
    salikkhan, Apr 11, 2011 IP
  2. Sepehr

    Sepehr Peon

    Messages:
    568
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The get method puts all the variables in the URL itself but post works differently.

    Overall it's recommended to use get when you have short variables and also when you want the url to be accessed even without the use of form(i.e. by using a url like domain.com/?page=profile&user=test).

    you might also want to read this:
    http://www.cs.tut.fi/~jkorpela/forms/methods.html
     
    Sepehr, Apr 11, 2011 IP
  3. salikkhan

    salikkhan Greenhorn

    Messages:
    75
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    18
    #3
    but in that case it will be prone to hacking? as the variable like username or password will be accessible.
     
    salikkhan, Apr 12, 2011 IP
  4. Sepehr

    Sepehr Peon

    Messages:
    568
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #4
    of course, you should never use get for user/pass, this way just by looking at the URL everyone'll know them!
     
    Sepehr, Apr 12, 2011 IP
  5. salikkhan

    salikkhan Greenhorn

    Messages:
    75
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    18
    #5
    so which one should i prefer for the username and passwords?
     
    salikkhan, Apr 12, 2011 IP
  6. Sepehr

    Sepehr Peon

    Messages:
    568
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I just said it, NEVER use GET for username and passwords.

    ALWAYS use POST!
     
    Sepehr, Apr 12, 2011 IP
  7. salikkhan

    salikkhan Greenhorn

    Messages:
    75
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    18
    #7
    is there any limit for the characters in these methods?
     
    salikkhan, Apr 12, 2011 IP
  8. Sepehr

    Sepehr Peon

    Messages:
    568
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Standard wise there is no limit but in practicality I don't think you can use more than 2000 chars in the URL.

    I personally think it's not any good to use inputs that each have more than 2-3 words in them with GET!
     
    Sepehr, Apr 12, 2011 IP