温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

php cookie控制提交频率

发布时间:2020-06-17 13:25:26 来源:网络 阅读:588 作者:liang3391 栏目:web开发
         //我要提问基于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("提交失败");
        
        }
          }); 
        }
向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI