Hi, I'm kind of new at PHP. Anyway, I have a login system on my site, and I would like to have a 'Userlist' of sorts that shows what pages the logged in users are on. Here is my main script, it is a file called users.php:

PHP Code:
<?php

session_start
(); #Start the session
include("getpage.php");

$hostname "localhost"#MySQL Hostname
$username "helloism_hellois"#MySQL Username
$password "*********"#MySQL Password
$database "helloism_login"#MySQL Database

$connect mysql_connect(localhosthelloism_hellois, *******); #Connect to the mysql host
$select_db mysql_select_db(helloism_login$connect); #Select the database

if (isset($_SESSION['PHPSESSID'])) { #If the user is logged in, good for them, if not, they become an ip address
$username $_SESSION['username']; #Username
} else {

$username $_SERVER['REMOTE_ADDR']; #Username is IP Address
}

$time time(); #Current time
$previous "1"#Time to check in seconds

$timeout $time-$previous#Timeout

$query "SELECT * FROM active_users WHERE username=\"$username\" AND timestamp < \"$timeout\""#Past 2 minutes

$verify mysql_query($query); #Execute query

$row_verify "mysql_fetch_assoc($verify)"#Check if you have been here in two minutes

if (!isset($row_verify['username']))  #See if you were found
$query "INSERT INTO online (username, timestamp) VALUES (\"$username\", \"$time\")"#Put you on the online list

$insert mysql_query($query); #Execute query

$query "SELECT * FROM active_users WHERE timestamp < \"$timeout\""#Check and see who is online
?>
<font size="3" face="Courier New" color="FFFFFF">
<?
$active_users 
mysql_query($query); #Execute query
$row_active_users "mysql_fetch_assoc($nowonline)";
if (isset(
$row_active_users['nowonline']))
{
do
{

echo (
$row_active_users['nowonline']."");


}

while(
$row_active_users mysql_fetch_assoc($active_users));

}

$online mysql_query($query); #Execute query
$row_online "mysql_fetch_assoc($username)"#Grab the users
if (isset($row_online['username']))

{
do
{

echo (
$row_online['username'].""); #Output username

echo '<br>';  #put a break after each database

}

while(
$row_online mysql_fetch_assoc($online)); #Until all records are displayed

} else {
echo 
"No one's online."#Inform user that no one is online
}

/* Grab current pages complete URL including after the question mark */    
echo $page// will show the full page
echo $QueryString// will show after ? 
// end of URL grab

?>
<title>[:Users Online:]</title>
</head>
<body bgcolor="000000" text="FFFFFF">
</body>
</html>


users.php does a good job of showing the users that are on ANY page in the site, but I would like it to point out specific pages the users are on. You may have noticed the getpage.php, I'll explain that next, it also deals with some of the last few lines. This is getpage.php:



PHP Code:
<?php
session_start
(); #Start the session

$hostname "localhost"#MySQL Hostname
$username "helloism_hellois"#MySQL Username
$password "*********"#MySQL Password
$database "helloism_login"#MySQL Database

$connect mysql_connect(localhosthelloism_hellois, *********); #Connect to the mysql host
$select_db mysql_select_db(helloism_login$connect); #Select the database

$QueryString="";
foreach (
$_GET as $key => $value)

$value urlencode(stripslashes($value));
if(
$QueryString!="")
$QueryString .="&";

$QueryString .= "$key=$value";
}

$pageName=basename($_SERVER['REQUEST_URI']);

$page =$pageName."?".$QueryString;

$query "INSERT INTO active_users (nowonline) VALUES ($page)";
$query "SELECT nowonline FROM active_users";
$verify mysql_query($query);

?>
Now... here's where the problem comes in. I have included getpage.php on every page that I want it to reflect the users' locations. I don't know if this is the correct tactic. I also don't know if the last three lines (query and verify lines) are correct. Whatever the case, my Userlist will NOT show the pages that the users are located on. In fact, it would show what users were anywhere on the site before I started tampering with getpage.php. Now I'm having to constantly recreate the active_users table to even get that to work. But my main focus is, to find the users' page locations. So maybe I could get a little help?