Home> PHP Framework> ThinkPHP> body text

ThinkPHP implements clicking on the picture to refresh the verification code

angryTom
Release: 2020-03-10 10:06:43
forward
4934 people have browsed it

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(); }
Copy after login

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(); }
Copy after login

Display the HTML code of the verification code image

Copy after login

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

For more ThinkPHP framework tutorials, please pay attention toPHP 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!

Related labels:
source:www.100txy.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!