View Full Version : Logout
pavmoxo
04-18-2006, 03:59 PM
How I can introduce in this line:
<span class="destqwhit">
<a href="alt_pass.php">Alterar Password</a> |
<a href="index.php?"> Logout</a>
</span>
the next PHP function for logout
//LOGOUT FORM
if($_POST["logout"] != "")
{
session_destroy();
echo "<meta http-equiv=\"refresh\" content=\"0;URL=index.php\">";
}
<a href="index.php?logout"> Logout</a>
if(isset($_GET["logout"]))
pavmoxo
04-18-2006, 04:15 PM
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?
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.
djr33
04-18-2006, 07:21 PM
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)
...doesn't it need a value?No, not if one is using isset (http://www.php.net/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.
djr33
04-18-2006, 07:36 PM
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']?
Yup, that'll give the URI used to request the page. Split it at "?" and parse the right-hand side.
djr33
04-19-2006, 06:02 AM
What's the easiest way to grab the right hand side? It becomes an array, right? Then I'd get like $array[2]?
Using explode(), yes. In this case, though, you've no need of the remainder, so you can use:
$uri = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], "?") + 1);
djr33
04-19-2006, 06:23 AM
why "+ 1"?
So as not to include the question mark itself.
djr33
04-19-2006, 06:26 AM
Ah, sure!.. thanks :)
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.