search
HomePHP FrameworkThinkPHPThinkPHP implements clicking on the picture to refresh the verification code

ThinkPHP implements clicking on the picture to refresh the verification code

Mar 10, 2020 am 10:06 AM
thinkphprefreshVerification code

This article introduces the method of using the thinkphp framework to refresh the verification code by clicking on the image. I hope it will be helpful to friends who are learning thinkphp!

ThinkPHP implements clicking on the picture to refresh the verification code

ThinkPHP implements clicking on the image to refresh the verification code

This type of verification code function refresh function involves two refreshes , one is to refresh by clicking on the verification code image, and the other is to refresh by entering the wrong verification code. Of course, don’t mention refreshing it yourself, it will definitely be refreshed.

(Recommended tutorial: thinkphp tutorial)

The thinkPHP framework has a built-in verify.class.php verification class. When we do verification code verification, it is very simple. Two verification formats are provided here, one is pure number, and the other is the system default. The methods inside are all methods written in the login controller. The specific code is as follows

//第一种默认的验证码
public function captcha(){
        $config =    array(
            'length'      =>    4,     // 验证码位数
        );
        $Verify = new \Think\Verify($config);
        $Verify->entry();
    }

The other one

//第二种默认的验证码
  function show_verify($config=''){
        if($config==''){
            $config=array(
                'codeSet'=>'1234567890',
                'fontSize'=>30,
                'useCurve'=>false,
                'imageH'=>60,
                'imageW'=>240,
                'length'=>4,
                'fontttf'=>'4.ttf',
                );
        }
        $verify=new \Think\Verify($config);
        return $verify->entry();
    }

Display the HTML code of the verification code image

   <div class="form-group">
      <input type="text" class="form-control" placeholder="验证码" required="" name="verify" >
      <img  class="verify lazy"  src="/static/imghwm/default1.png"  data-src="{:U(&#39;Admin/Login/show_verify&#39;)}"    title="点击更换"  onclick="this.src+=&#39;&#39;;" alt="ThinkPHP implements clicking on the picture to refresh the verification code" >
    </div>

The picture onclick event can complete the refresh of the verification code

For more ThinkPHP framework tutorials, please pay attention to PHP Chinese website!

The above is the detailed content of ThinkPHP implements clicking on the picture to refresh the verification code. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:www.100txy.com. If there is any infringement, please contact admin@php.cn delete

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft