1. Home
  2. Computing & Technology
  3. PHP / MySQL

You Last Visited PHP Script

By Angela Bradley, About.com

3 of 4

Welcome Back

if (isset ($last))
{
$change = time () - $last;
if ( $change > 86400)
{
echo "Welcome back! <br> You last visited on ". date("m/d/y",$last) ;
// Tells the user when they last visited if it was over a day ago
}
else
{
echo "Thanks for using our site!";
//Gives the user a message if they are visiting again in the same day
}
}
This code first checks if $last is set. If you remember from the last step, $last is the time the visitor was last at the site. If they have visited before it then runs through two options. If the visitor has visited within the last day, it simply thanks them for visiting the site. If however the visitor visited over 1 day (86,400 seconds) ago, the message welcomes them back and reminds them of when they last visited.
Explore PHP / MySQL
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. PHP / MySQL
  4. Step By Steps
  5. Your Last Visit Script - PHP Last Visit Script - Last Time Visited PHP

©2009 About.com, a part of The New York Times Company.

All rights reserved.