thinkphp限制IP

1 、 首先判定得到IP数据

//客户ip地址 $get_real_ip = get_client_ip(0);
 $this->assign('getip',$get_real_ip);
 
2、插入数据库, 进行数据比对
$reg_ip = $this->_post('real_ip');
 //查询IP的个数 >3 就报错
 //$count = M("alumni_reg")->where("real_ip1='".$reg_ip."'")->count('rid');

 $count = M("person_reg")
 ->where("real_ip='".$reg_ip."'")
 ->field('*')
 ->count();
 //var_dump("1628");
 //var_dump($count);
 //var_dump($reg_ip);
 //die;
 var_dump(intval($count));

3、根据count数, 决定是否插入数据库!!

原文链接: thinkphp限制IP 版权所有,转载时请注明出处,违者必究。
注明出处格式:流沙团 ( http://gyarmy.com/post-244.html )

发表评论

0则评论给“thinkphp限制IP”