zoukankan      html  css  js  c++  java
  • thinkphp3.2 验证码生成和点击刷新验证码

    生成验证码的时候:

    public function verify_c(){  
        $Verify = new ThinkVerify();  
        $Verify->fontSize = 18;  
        $Verify->length   = 4;  
        $Verify->useNoise = false;  
        $Verify->codeSet = '0123456789';  
        $Verify->imageW = 130;  
        $Verify->imageH = 50;  
        //$Verify->expire = 600;  
        $Verify->entry();  
    }  
    

      

    <p class="top15 captcha" id="captcha-container">  
      <input name="verify" width="50%" height="50" class="captcha-text" placeholder="验证码" type="text">                  
      <img width="30%" class="left15" height="50" alt="验证码" src="{:U('Home/Index/verify_c',array())}" title="点击刷新">  
    </p> 
    

      

        $(function () {
            var captcha_img = $('#captcha-container').find('img')
            var verifyimg = captcha_img.attr("src");
            captcha_img.attr('title', '点击刷新');
            captcha_img.click(function(){
                if( verifyimg.indexOf('?')>0){
                    $(this).attr("src", verifyimg+'&random='+Math.random());
                }else{
                    $(this).attr("src", verifyimg.replace(/?.*$/,'')+'?'+Math.random());
                }
            });
        })
    

      验证在common.php中添加方法

         

    function check_verify($code, $id = ""){  
        $verify = new ThinkVerify();  
        return $verify->check($code, $id);  
    } 
    

      提交表单的时候:

    $verify = I('param.verify','');  
    if(!check_verify($verify)){  
        $this->error("亲,验证码输错了哦!",$this->site_url,9);  
    } 
    

      

  • 相关阅读:
    Linux监控内核SNMP计数器
    wireshark使用手册
    【LinuxShell】echo用法详解
    【Coredump】调试之旅
    汇编指令
    从零开始学Java (五)条件选择
    从零开始学Java (四)输入输出
    Dart基础
    树相关
    递归简介
  • 原文地址:https://www.cnblogs.com/xqschool/p/6274169.html
Copyright © 2011-2022 走看看