if(!empty($username)){ //已经登陆 检查session
$sql="select * from useronline where username='$username'";
$sel->query($sql);
$num=$sel->nf(); //在线人员中有没有此用户 没有就插入 有就更新一下时间
if($num!=0){
$sql="insert into useronline(username) values ('$username')";
add->query($sql);
}else{
。。。。。//更新时间 update set time='time()'
}
}
else{
同上 检查是否有$REMOTE_ADDR 没有就插入username 为访客的记录
有就更新一下时间
}
删除在 多少 时间内无动作的记录
if(fopen("http://....","r"

{
head(location:http...);
}
else{
head(location:其他页);