Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Mar 2006
    Posts
    478
    Thanks
    3
    Thanked 0 Times in 0 Posts

    logout page refresh to itself.

    i am trying to get the page to revisit itself one the members is logged out, but on refresh it will not try to log them out as they will not be online anymore due to the $user = NULL so the refresh will only run once, but it does not even run the once due to the headers already being sent.

    <?php // this file is logout.php
    if ($user) {
    $res = mysql_query("UPDATE `membersonline` SET `status` = 'LOGGEDOUT' WHERE `user` = '".$user."' LIMIT 1") or die(mysql_error());
    mysql_close();
    $user = "";


    // the rest works but the next line
    header ("Refresh: 0; URL=http://site.com/logout.php");


    }
    ?>
    <p align="center">&nbsp;</p>
    <p align="center">&nbsp;</p>
    <p align="center">You are no longer logged in.</p>
    <p align="center">Thank you for visiting <?=$sitename;?></p>
    <p align="center">&nbsp;</p>
    <p align="center">&nbsp;</p>

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Though I didn't get your requirement completely, the php header() functions requires to be called before any actual output is sent (ie there shoudn't be any echo/print statements or html before this)
    See the manual.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Regular Coder
    Join Date
    Mar 2006
    Posts
    478
    Thanks
    3
    Thanked 0 Times in 0 Posts
    i know that but it is an example of what i was trying to do.

    how can i get the page to refresh/revisit.

    obviously it will not repeat this process again as the member will have been logged out the first time.

  • #4
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    You could use a meta refresh, but if you process the logout before the page is loaded you won't need to reload it; just show the appropriate content. Keep in mind that $user by itself will not persist across pageloads. You'll have to use a $_SESSION or $_COOKIE for that.

  • #5
    Regular Coder the-dream's Avatar
    Join Date
    Mar 2007
    Location
    Northamptonshire, UK
    Posts
    477
    Thanks
    8
    Thanked 4 Times in 4 Posts
    What about...

    PHP Code:
    if($user == NULL) {

    } else {
          
    // Logout Code



  •  

    Posting Permissions

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