I have installed this in a script I'm working on. It will display who is currently on-line and links to their information.
$timeoutseconds=300; // Timeout value in seconds
$timestamp=time();
$timeout=$timestamp-$timeoutseconds;
mysql_connect($server, $db_user, $db_pass) or die ("Useronline Database CONNECT Error");
mysql_db_query($db_name, "INSERT INTO useronline VALUES ('$timestamp','$REMOTE_ADDR','$PHP_SELF','$username','$id')") or die("Useronline Database INSERT Error");
mysql_db_query($db_name, "DELETE FROM useronline WHERE timestamp<$timeout") or die("Useronline Database DELETE Error");
$result=mysql_db_query($db_name, "SELECT id, username FROM useronline WHERE file='$PHP_SELF'") or die("Useronline Database SELECT Error");
/$users=mysql_fetch_array($result);
/$user=mysql_num_rows($users);
mysql_close();
if ($user>0) {*/
$on_string =" ";
while ($geton_now = mysql_fetch_array($result))
{
$online_id = $geton_now['id'];
$contact_username2 = $geton_now['username'];
$on_string .="<a href=\"show_contact.php?id=$id\">$contact_username2</a> ";
}
the database table needs the following:
timestamp
ip
file
username
id
It took me awhile to figure this one out, and it works great
Enjoy