1

i currently have my site configured so that when a user logs in they are navigated to the home page of my site and they get a welcome message within a session. the bit im having trouble with is finding a way to timeout or close this message or chage the css settings to display:none after 3 seconds.

Can someone please show me how i could add a time out function onto this, heres what i got so far, thanks.

User logs in using html login form, this submits and goes to login.php:

inside login.php i have this:

<?php
if (logged_in()) 
{ 
$_SESSION['login_message']="<div class=\"login-overlay\">
<h1>Login You In Securely</h1></div>"; 
header("Location:home.php");

}
?>

Then inside home.php i have this:

<?
session_start();
if(isset($_SESSION['login_message'] ))
   echo $_SESSION['login_message'];
    unset($_SESSION['login_message']) ;

?>

how can i add a 3 second rule to this so that it only shows for 3 seconds thanks.

user3080996
  • 29
  • 4
  • 7
  • Why to use PHP for this functionality. Use JQUERY setTimeout `setTimeout(function() { // Do something after 5 seconds }, 5000);` – Uday Hiwarale Dec 09 '13 at 17:09

2 Answers2

3

Use javascript.

setTimeout(function() {
  document.getElementById("message").style.display = 'none';
}, 3000);

javascript hide/show element

Community
  • 1
  • 1
Dan Grahn
  • 9,044
  • 4
  • 37
  • 74
1

You can use jquery,

$(function(){
   setTimeout(function() {
       $("#message").hide('slow');
   }, 3000);
});
Krish R
  • 22,583
  • 7
  • 50
  • 59