流沙团
thinkphp限制IP
2017-6-15 流沙团


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数, 决定是否插入数据库!!

发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容