Logout Button In PHP?
Hey guys,
Im new to php, and i was wondering how i could create a log out button for my page? I have a logout.php page and i need a button to redirect to there when users click on logout.Any ideas?
2 Answers
if you want it as a button you must use form tag ok
this is the form: <form action="logout.php" method="post"> <input name="return" type="hidden" value="<?php echo urlencode($_SERVER["PHP_SELF"]);?>" /> <input type="submit" value="logout" /> </form>this is the logout code: if (isset($_POST['return'])) { $return = urldecode('http://www.mysite.com'.$_POST['return']); header("Location: $return"); exit; } Posted: MacOS 2 of 2 people found this answer helpful. Did you? Yes No
its very easy like this logout.php?return=/home
logout.php if (isset($_GET[\'return\'])) { $return = urldecode(\'http://www.mysite.com\'.$_GET[\'return\']); header(\"Location: $return\"); exit; }ok but how i can get the logout.php?return=/home in each page Automaticly there is too many ways just try this way <a href=\"logout.php?return=<?php echo urlencode($_SERVER[\"PHP_SELF\"]);?>\">log out</a> Posted: MacOS 1 of 1 people found this answer helpful. Did you? Yes No I already have the code for logout.php.I just need to know how i can use a button instead of a hyperlink to actually log the user out.Like the login has a button but i want to know how to create a button to log the user out? |
© Advanced Web Core. All rights reserved