简体   繁体   中英

I want to load a gif image when user clicks on logout and then redirects to home page. i am trying to do using php

I have a page(era.php) which has a logout option. When user clicks on logout, it calls logout.php which destroys session and has header too index: header('Location: index.php'); This all is working fine. But, i want some gif image to be loaded when user clicks on logout and then it redirects to index. It is very quick now...actually i want to add some delay which shows some image saying Redirecting.. something.

You can use a logout.php as a middleman, without header redirection and do any action in that page.

Eg removing the current session, showing an html message and redirecting with javascript after x seconds.

Update: You can use the a meta tag to refresh the page. W3C page

I have done this and is working although: When a user clicks on "logout" load.php is loaded: Here it is:(i have passed Get request because if user tries to open load.php through url) load.php

<?php
session_start();
if(!isset($_SESSION['user_id']) || !isset($_SESSION['user_name']) ||   !isset($_SESSION['user_right']))
    header('Location: .');
if(isset($_GET['val']))
{
 if($_GET['val']=='out')
 { 
?>
<html>
<head>
<title>Redirecting..</title>
</head>
<body>
<div style="margin: 250px 0px 0px 600px;">
    <div>
        <img src="img/301.gif">
    </div>
</div>
</body>
</html>
<?php
  header("refresh:5;url=logout");
  }
}
else
 header('Location:.');
?>

And, then logout.php destroys session and calls the index.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM