SitePoint Sponsor

User Tag List

View Poll Results: Which METHOD is BETTER and WHY ? (GET vs POST)

Voters
35. You may not vote on this poll
  • GET

    3 8.57%
  • POST

    29 82.86%
  • Other (If any)

    3 8.57%
Page 3 of 4 FirstFirst 1234 LastLast
Results 51 to 75 of 85
  1. #51
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No body told me so far, what if i opt to use GET for a FORM and use encryption method to protect. is it applicalbe ?

  2. #52
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can probably encrypt information and send them along a form, but what's the purpose ? Normally a request implies that the user wants to convey some information. If you encrypt it, they won't be able to do that - only you can construct meaningful url's. A much better solution is to validate/filter the input from users to protect against hacking-attempts. For example, this is why you should always escape strings when inserting into a database.

  3. #53
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is that really important to escape strings ??? I think RegExp is a better choice, isn't it ?

  4. #54
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by zeeshanhashmi
    No body told me so far, what if i opt to use GET for a FORM and use encryption method to protect. is it applicalbe ?
    You seem to be having a hard time wrapping your head around the general principle. I can sympathize, I often have trouble with things until they "click". Try this, sorry if it is obvious, but maybe it will help.

    When you are trying to decide between GET and POST, think about whether or not you want the form information to end up bookmarked.

    So let's say you have a form for sending an email. If it uses GET, you may end up with a url like this:
    http://example.com/feedback.php?re=site&text=I-love-your-site

    So the user finishes sending that email and right then it occurs to them that they should really bookmark your site since they like it so much. If the user bookmarks that page right then, every time they use that bookmark a new email will be sent. If someone links to that page, search bots may find it and hit it hundreds of times. That's probably not what you want!

    Encrypting the data doesn't really change the nature of the problem.

    In the above example, something you intended to happen once (sending the feedback email) will happen each time they access that page. That's what's meant by "lasting effect", sending the email should be a lasting effect that happens once and then doesn't happen again without the user filling out a new form. So POST would be appropriate. The page bookmarked would look like this:
    http://example.com/feedback.php
    ... and instead of an email being sent each request, the user would get an error message and maybe some friendly options.

    In contrast, if the user is looking for a definition you'd want them to be able to bookmark:
    http://example.com/define.php?w=potato
    That way users could bookmark the page so they know where to go for that particular definition and can link to that page to show other people the defintion.

    However, if you allowed users to add definitions you wouldn't want to use GET. If you allowed this:
    http://example.com/addDefinition.php?w=potato&d=root-vegetable
    Someone might bookmark that page or link to it and you'd get hundreds of duplicate entries for potato. Better to use POST there!

    Ok, so does that help ... at all?
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  5. #55
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Marvellous samsm great description. Actaully i have a good idea of GET and POST, and to ask the experts is my right. Ask people in order to know something is not a bad habbit at all. Anyways, I the detials u provide with the example of bookmark is really good. Thanks

  6. #56
    SitePoint Evangelist mrwooster's Avatar
    Join Date
    Jan 2006
    Posts
    518
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Remember that most browsers will show a warning box if a user tries to re-submit a POST, so you don't want to use it for searches and suchlike as users will have dialog boxes popping up all over the place.

  7. #57
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah u are right. Agreed !

  8. #58
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    People said that POST vs GET is like Apple vs Bicycle..... I agreed. Even thoug people took part in vote and what i see is that POST is winning but HEAVY MARGIN. I will apprecaite if someone summup this discussion by giving the situations (though i got the complete understanding, i want this to be posted here in order to HELP newbies...) where POST is favorable with live examlpe and with Get as well all in one post. IS There ANYONE ?

  9. #59
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,270
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by zeeshanhashmi
    I will apprecaite if someone summup this discussion by giving the situations (though i got the complete understanding, i want this to be posted here in order to HELP newbies...)
    i think you should do this
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  10. #60
    Wadge! F4nat1c's Avatar
    Join Date
    Oct 2005
    Location
    South Wales, UK
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Check: http://www.cs.tut.fi/~jkorpela/forms/methods.html

    I think it's just become common practice among most programmers to use the $_POST method.
    OMFG SitePoint ROXORZ TEH BIG ONE111!
    Wish you were invisible?

  11. #61
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah for the same reason i post this thread

  12. #62
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    new people are welcom to vote and post their comments....

  13. #63
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by zeeshanhashmi
    new people are welcom to vote and post their comments....
    The information and resources already provided in this thread, should be enough to give you a decent concept of the difference between post and get.

    I'm seconding Rudy. Why not take that information and sum it up for us?
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  14. #64
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Althoug I ahve got the understanding, I m not that much GOOD at summing up. So I welcome people to come up with someting great...... Thanks

  15. #65
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by zeeshanhashmi
    Althoug I ahve got the understanding, I m not that much GOOD at summing up. So I welcome people to come up with someting great...... Thanks
    Don't OPT to Loss
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  16. #66
    SitePoint Evangelist Will Kelly's Avatar
    Join Date
    May 2005
    Location
    London
    Posts
    475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great summary.

    I'm registering the domain name right now...

  17. #67
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ha ha ha good samsm, I didnt opt to loss. There are really GURUS of PHP, and I m not 1 of them since i have just started PHP. I want gurus like u people (and u too Will Kelly) to come and have this honor.

  18. #68
    SitePoint Evangelist Will Kelly's Avatar
    Join Date
    May 2005
    Location
    London
    Posts
    475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm feeling mildly insulted. :'(

    ___________________________
    'Never give up! Never surrender!'

  19. #69
    Keep it simple, stupid! bokehman's Avatar
    Join Date
    Jul 2005
    Posts
    1,935
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by zeeshanhashmi
    ha ha ha good samsm, I didnt opt to loss. There are really GURUS of PHP, and I m not 1 of them since i have just started PHP. I want gurus like u people (and u too Will Kelly) to come and have this honor.
    Why would anyone bother wasting their valuable time summing up this boring thread which will soon be archived never to be read again.

  20. #70
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,270
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    FYI it should be "Don't OPT to lose"

    loss is a noun, lose is a verb (and loose is almost always an adjective!!)
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  21. #71
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this is a mystry. U people can't understand that the Difference of Loss and Lose.... anyways, Will Kelly do not feel insulted. and ..... ok what ever, its fine.

  22. #72
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,270
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    it's mystery, not mystry
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  23. #73
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah yeah, u r right. So the Summary Part 1 Written by me is :

    POST Vs. GET
    POST and GET are not functions, they are actually variables. The Get variable will attach to the URL as: http://www.site.com/script.php?post=input_text
    This is not as secure as Post, which will hide information being sent. Get will allow the user to modify input_text to change parameters of the script.
    These variables are used to pass in data from a form to variables in the script.
    To make things easier for forms processing, they are split up into two files. One is the html file that is supposed to take input from the user. The other file is the php file and it does the processing.

  24. #74
    Keep it simple, stupid! bokehman's Avatar
    Join Date
    Jul 2005
    Posts
    1,935
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by zeeshanhashmi
    POST and GET are not functions, they are actually variables.
    Actually they are neither functions nor variables, they are in fact methods. And by the way don't give up your day job.

  25. #75
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nice bokehman, how wud u define Methods and Functions ????


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •