Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 30th, 2012  |  syntax: None  |  size: 0.82 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. PHP - consecutive page visits
  2. // first you need to set $last seen from the DB..
  3. // first you need to set consecutive from the DB too..
  4. // once you have, you can do something like this.
  5. if(strtotime('-1 day', date('Y-m-d')) == $last_seen) {
  6.     $consecutive = $consecutive + 1;
  7.     mysql_query(sprintf('UPDATE user SET last_seen=NOW(),consecutive=%d WHERE id=%d', $consecutive + 1, $id));
  8. } else if(date('Y-m-d') == $last_seen) {
  9.     // ok, they logged in today again, do nothing.
  10. } else {
  11.     $consecutive = 0; // only really needed if you plan on displaying it to the user
  12.                       // later in this script
  13.     mysql_query(sprintf('UPDATE user SET last_seen=NOW(),consecutive=0 WHERE id=%d',$id));
  14. }
  15.        
  16. if(isset($_COOKIE["identifier"])){
  17.    // log as existing user
  18. }else{
  19.   setcookie('identifier', $id_value, ...
  20. }