码迷,mamicode.com
首页 > Web开发 > 详细

php cookie控制提交频率

时间:2016-07-01 16:44:00      阅读:230      评论:0      收藏:0      [点我收藏+]

标签:php cookie控制提交频率

         //我要提问基于tp3.2
            public function tiwen(){
                $cityId = parent::$cityId;//区分城市id
                $typeDb=D("FangType");
                $typeData=$typeDb->getConfig(36,$cityId);
                $this->assign("typeData",$typeData);
                if($_POST){
                $db = D("EsfAsk");
                $userid=  $this->userId;
                $asktypeid=I(‘asktypeid‘);
                $asktitle=I(‘asktitle‘);
                $data[‘askType‘] = $asktypeid;
                $data[‘askTitle‘] = $asktitle;
                $data[‘description‘] =$asktitle;
                $data[‘askTime‘] = time();
                $cookie = cookie(‘bresfwd‘);
                cookie(‘bresfwd‘,"Y",array(‘expire‘=>60));
                if($cookie){
                      $this->success(‘提交过于频繁‘);
                } 
               
                
                $data[‘cityId‘]=$cityId;
                $data[‘userId‘] = $userid;
                $data[‘isAnswer‘] = ‘N‘;
                $data = $db->add($data);
                if ($data) {
                    $this->success(‘提交成功‘);
                } else {
                    $this->success(‘提交失败‘);
                }
             }
                $this->display(); 
            }
js代码:
<!--提问-->
<script>
    function tijiao(){
     var asktypeid=document.getElementsByClassName(‘active‘)[0].value;
  
      var asktitle=$("#askTitle").val();    
      
      $.post("/Esf/Ask/tiwen",{asktypeid:asktypeid,asktitle:asktitle},function(data){
            if(data.status==1){
             layer.msg(data.info);//根据返回提示
             window.location.href=window.location.href;
      
            }else {
               
         layer.msg("提交失败");
        
        }
          }); 
        }

本文出自 “PHP/Linux@HeFei” 博客,转载请与作者联系!

php cookie控制提交频率

标签:php cookie控制提交频率

原文地址:http://liang3391.blog.51cto.com/178205/1794775

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!