Well I was setting the time backwards 2 hours inside my database lol.. But I was doing it the way you said just now, yesterday. and yeah.. it stil wasn't working..
I'm really frustrated right now with PHP not understanding me.. Nobody understands me >.< lol.. except you Daevius.
But anyway, I origonally had it as post until I started making links like href="thisURL.php?logout=LogMeOut"
So since I was using $_POST and $_GET both to log ppl out, then I decided to just use $_REQUEST which works for both, instead of doing if(isset($_POST..)) {} else if(isset($_GET..)) {}
But if it's not gonna work, it's not gonna work. I'll just setup the display so it displays ppl online if they were active 10 minutes ago.. The update last_edited works everytime you refresh any page with a session. I'll just say:
if( (strtotime($last_edited)+600)-$time > 1) {
print '<small><span style="color: #00CC00;">Online Now!</span></small>';
}
That way I'm just taking out a step and it should still be effective for the job it's titled to.. - Display ppl onine -
EDIT: I got it working pretty good now.
Basicly, I just do this query on every page:
PHP Code:
$update='update `users` SET `last_action` = NOW() where `userID`= '.$_SESSION['SessionID'].' LIMIT 1';
There's really no reason for a limit, since I don't think it's even possible to do UPDATE *(All) ... And default is 1..
Anyway, I load the table to the page, and it goes through this code:
PHP Code:
<?php
if( (strtotime($last_edited)+600)-time() > 1) {
print '<br><small><span style="color: #00CC00;"><strong>Online Now!</strong></span></small>';
} else {
list($date,$time) = split(" ", $last_edited);
list($yr,$month,$day) = split("-",$date);
// Month change:
if($month=="01") {
$month="Jan";
}
else if($month=="02") {
$month="Feb";
}
else if($month=="03") {
$month="March";
}
else if($month=="04") {
$month="April";
}
else if($month=="05") {
$month="May";
}
else if($month=="06") {
$month="June";
}
else if($month=="07") {
$month="July";
}
else if($month=="08") {
$month="Aug";
}
else if($month=="09") {
$month="Sep";
}
else if($month=="10") {
$month="Oct";
}
else if($month=="11") {
$month="Nov";
}
else if($month=="12") {
$month="Dec";
}
if($day < 10) {
list($zero,$day)=split("0",$day);
}
print '<br><small><span style="color: #990000;">Last Online: <i>'.$month.' '.$day.', '.$yr.'</i></span></small>';
}
?>
If the user is online, say:
Online Now!
else, say last log-in (ex.):
Last Login: Aug. 1, 2008
I put this^ code on the main profile page.
I only ask if the user is online on the friendlist and comments area. I don't put the: [Last Login:...] bit on those areas; Just [Online Now!].