웹마스터 팁

http://210.182.239.178:8080/ex/egguser.php테이블 생성
=======================
create table user_save(
ipaddr varchar(20),
visit_time varchar(30);

=======================

이하 소스
======================
<?

$connect = mysql_connect("localhost","ID","PASSWORD");

mysql_select_db("DB_NAME",$connect);

$your_ip = $REMOTE_ADDR;
$time = time();


$query = "delete from user_save where visit_time < $time - 40 " ;  //40초 이상 차이나는것 삭제

mysql_query($query,$connect);




$query = "select ipaddr from user_save where ipaddr='$your_ip'"; //아이피리스트중에 이미 있는거만 고르기

$result = mysql_query($query,$connect);

$user = mysql_fetch_row($result);

if (!$user){   //저장된 아이피가 없으면 기록한다

$query = "insert into user_save (ipaddr,visit_time) values ('$your_ip','$time')";  //저장

mysql_query($query,$connect);

}


$query = "select count(*) from user_save"; //현제 접속자

$result= mysql_query($query,$connect);

$connected = mysql_fetch_row($result);

if ($connected[0] == "0"){
$connected[0] ="1";
}


//echo "총 접속자 : $connected[0]";

?>