
wordpress不用插件如何实现访客统计,方法很简单,下面web建站小编给大家讲解一下步骤!
1、新建一个wp_count表
id ip times
2、建一个count.php文件
<?php
//连接数据库
$conn=mysql_connect("localhost","root","123456");
if(!$conn){
die("链接失败".mysql_errno());
}
//设置数据库编码方式
mysql_query("set names utf8",$conn) or die(mysql_errno());
//选择数据库
mysql_select_db("wordpress",$conn) or die(mysql_errno());
$adress=$_SERVER["REMOTE_ADDR"];
//将本次访客的ip地址添加到数据库中
$sql="select times from wp_count where ip='$adress'";
$res=mysql_query($sql,$conn);
if(!$row=mysql_fetch_row($res)){
$sql="insert into wp_count(ip, times) values('$adress','1')";
}else{
$times = $row['0']+1;
$sql="update wp_count set times='$times' where ip='$adress'";
}
$res=mysql_query($sql,$conn);
//发送语句获取总数
$sql="select count(ip) from wp_count";
$res=mysql_query($sql,$conn);
if($row=mysql_fetch_row($res)){
$num=$row['0'];
}
echo"您是第 "."$num"." 位访客"."您的ip地址是"."$adress";
mysql_close();
?>
标签: 访客统计
上面是“wordpress不用插件如何实现访客统计”的全面内容,想了解更多关于 wordpress 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_2489.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

盘点原神挪德卡莱12位新角色
Genspark APP最新版
vegaai官网:支持文生图、图生图、风格转换、姿势生图等