独家访问网站

时间:2015-07-05 20:27:18

标签: php mysql unique counter

我将如何制作它以便只有唯一的IP地址才能增加计数?代码工作正常,除了事实

<?php 
include('core/init.php');
banned_redirect();
include('includes/overall/header.php');

$counter='';//initilize counter
$sql="SELECT counter FROM tb_counter";
$result=mysql_query($sql);
$rows=mysql_fetch_assoc($result);
$counter=$rows['counter'];

// if count is empty
if(empty($counter)){
$counter=1;
$insertCounter="INSERT INTO tb_counter set counter='".$counter."'";
$result1=mysql_query($insertCounter);
}

echo "You are visitor num=>". $counter;

// increment visitor count
$increasecounter=$counter+1;
$sql2="update tb_counter set counter='".$increasecounter."'";
$result2=mysql_query($sql2);
?>

0 个答案:

没有答案