Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Logout

  1. #1
    Join Date
    Apr 2006
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Arrow Logout

    How I can introduce in this line:



    Code:
    <span class="destqwhit">
    	<a href="alt_pass.php">Alterar Password</a> |
    	<a href="index.php?"> Logout</a>
    	</span>
    the next PHP function for logout

    Code:
    //LOGOUT FORM
    	if($_POST["logout"] != "")
    	{
    		session_destroy();
    		echo "<meta http-equiv=\"refresh\" content=\"0;URL=index.php\">";
    	}

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    <a href="index.php?logout"> Logout</a>
    Code:
    if(isset($_GET["logout"]))
    Last edited by Twey; 04-18-2006 at 04:19 PM.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Apr 2006
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    It continues not to give because when I click BACK in the browser it returns without problems

    With the code button:

    <input name="logout" type="submit" class="frm3" value="Logout">

    it closes the session!!

    Any sugestion?

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    With GET, sorry. Edited.
    If you click "Back" in your browser it will show the logged-in page anyway, because it will likely be read straight from the browser's cache.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Don't you need it to be set to something? Guess not, but how does that work?

    What I'm asking:
    index.php?logout
    vs.
    index.php?logout=yes
    ...doesn't it need a value?

    (also, I've seen pages where it's like display.php?pictures, and then pictures are displayed, as opposed to perhaps 'text'. how do you get that value if the var name is changing? can you have more than one? index.php?1&2)

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    ...doesn't it need a value?
    No, not if one is using isset(). The GET variable is set even if it doesn't have a value; it'll just be a blank string. But in this case, that's all that is needed. One should always use isset() if one is not sure whether the variable or array item will exist or not anyway.
    (also, I've seen pages where it's like display.php?pictures, and then pictures are displayed, as opposed to perhaps 'text'. how do you get that value if the var name is changing?
    if-else statements One can also parse $_SERVER['REQUEST_URI'] if one wants a more flexible solution.
    can you have more than one? index.php?1&2)
    Yes.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Well, one place I saw that was on cr3ative's file hosting site, where the tag was the thing after the question mark...
    view.php?tag
    and then it got the tag, and used that... can't be if/else as user input worked for that.

    So... $_SERVER['REQUEST_URI']?

  8. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Yup, that'll give the URI used to request the page. Split it at "?" and parse the right-hand side.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  9. #9
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    What's the easiest way to grab the right hand side? It becomes an array, right? Then I'd get like $array[2]?

  10. #10
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Using explode(), yes. In this case, though, you've no need of the remainder, so you can use:
    Code:
    $uri = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], "?") + 1);
    Last edited by Twey; 04-19-2006 at 06:27 AM.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

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
  •