Simple PHP question...

Discussion in 'PHP' started by MCJim, Aug 23, 2008.

  1. #1
    What does the '?' mean in some links after .php? Example:
    http://thisisjustanexamplelink.com/login.php?do=logout

    I ask this because I'm making a logout link on my site, and I noticed that other websites use this method.

    Very newbie question, but I didn't see it on the tutorial I'm reading. Thanks in advance!:eek:
     
    MCJim, Aug 23, 2008 IP
  2. ForumJoiner

    ForumJoiner Active Member

    Messages:
    762
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    83
    #2
    When you pass variables to your script, you can use the POST or the GET method.
    Variables posted by the GET method look like ?variable=value, or ?variable1=value1&variable2=value2
    The variables posted by the POST method do not appear after the link.

    In your case, it means that the action to do is "logout".

    You can find more details here:
    http://www.php.net/reserved.variables
    (more exactly:
    http://www.php.net/manual/en/reserved.variables.get.php
    http://www.php.net/manual/en/reserved.variables.post.php)

    You should do yourself a favor and read this:
    http://www.securereality.com.au/studyinscarlet.txt

    It's both shocking and useful :)
     
    ForumJoiner, Aug 23, 2008 IP
  3. MCJim

    MCJim Peon

    Messages:
    163
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Ahh... this makes sense, thanks. I did not notice this because I've only been using POST. Is it good to use POST instead of GET? It seems much cleaner in the URL. I assume it depends on the situation...

    I'll read that security txt file.
     
    MCJim, Aug 23, 2008 IP
  4. ForumJoiner

    ForumJoiner Active Member

    Messages:
    762
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    83
    #4
    If you use GET, it's obvious which names you use for variables. If you use POST, some pages will not have links that can be bookmarked.
    For instance:
    I can bookmark http://mysite.com/index.php?section=tutorials,
    but if I use POST, the tutorial section will have the same link as the main page, because the POST values are not visible.

    Another way is to use http://mysite.com/tutorials, and internally to translate this to POST or GET
    (WordPress does this, for instance)
     
    ForumJoiner, Aug 23, 2008 IP