zoukankan      html  css  js  c++  java
  • TP5.1 验证码验证错误

     

    Ajax 验证因为是onblur 验证总是提交两次数据,第一次对,第二次错。

    思考一下,肯定是session 被清空了,

    找到验证码配置里面有一项是验证后是否重置

    // 验证成功后是否重置

                'reset'    =>    false

     

    // 验证码

        public function verify()

        {

            $config =    [

                // 验证码字体大小

                'fontSize'    =>    13,

                // 验证码位数

                'length'      =>    4,

                // 关闭验证码杂点

                'useNoise'    =>    false,

                  

            ];

     

            $captcha = new Captcha($config);

            return $captcha->entry();

        }

     

       

        public function checkcapcha()

        {

            $config = array(

                'reset' => false // 验证成功后是否重置,—————这里才是有效的。

            );

            $captcha = new Captcha($config);

            $code   =  input('captcha');

            if!$captcha->check($code))

            {

                 return false;

            }else{

                return true;

            }

        }

     

    但是需要加到,check里面而不是获取验证码的config里面。此坑需注意!

     

    文章来源:刘俊涛的博客 欢迎关注公众号、留言、评论,一起学习。

     

    若有帮助到您,欢迎点击推荐,您的支持是对我坚持最好的肯定(*^_^*)

  • 相关阅读:
    200. Number of Islands 200.岛屿数(可以形状一样)
    695. Max Area of Island最大岛屿面积
    springboot如何在项目启动时初始化资源
    springboot之集成Memcached
    springboot之spring-boot-admin对springboot服务进行监控
    springboot之集成FastDFS
    springboot之上传文件
    springboot之整合shiro-登录认证和权限管理
    springboot 如何测试打包部署
    springboot之Mongo
  • 原文地址:https://www.cnblogs.com/lovebing/p/12420659.html
Copyright © 2011-2022 走看看