Hi, im new here and would like some help from you
i have this code which detects how many guests and members there are currently on my website. here is the code below
[code]<?php
include(‘config.php’);
include(‘functions.php’);
mysql_connect($server,$dbusername,$dbpassword);
mysql_select_db($db_name);
$uname = $_SESSION[‘user_name’];
if (!$uname)
{
$guest = 1;
} else
{
$guest = 0;
}
$ip = $_SERVER[“REMOTE_ADDR”];
$time = time();
$page = $_SERVER[“PHP_SELF”];
$query = “SELECT * FROM user_online WHERE ip = ‘$ip’”;
$result = mysql_query($query);
if (mysql_num_rows($result) == 1)
{
$query2 = “UPDATE user_online SET uname=’$uname’,time=’$time’,file=’$page’,guest=’$guest’ WHERE ip = ‘$ip’”;
$result2 = mysql_query($query2);
}
else
{
$query2 = “INSERT INTO user_online (uname
, ip
, time
, file
, guest
) VALUES (’$uname’, ‘$ip’, ‘$time’, ‘$page’, ‘guest’)”;
$result2 = mysql_query($query2);
}
$query4 = “SELECT * FROM user_online WHERE guest = ‘1’”;
$result4 = mysql_query($query4);
$guestonline = mysql_num_rows($result4);
$query5 = “SELECT * FROM user_online WHERE guest = ‘0’”;
$result5 = mysql_query($query5);
$memonline = mysql_num_rows($result5);
echo "
Guests: $guestonline
Members: $memonline
";
?>[/code]
Now how do i proceed if i want the code to remove the guest from the database once he has stop viewing the website??
and how do i proceed if i want the code to remove the logged users once he has logged out?
I manage to make it this far but can’t seem to find a solution now… any help would me much appreciated!