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
What Are the Key Features of ThinkPHP's Built-in Testing Framework?What Are the Key Features of ThinkPHP's Built-in Testing Framework?Mar 18, 2025 pm 05:01 PM

The article discusses ThinkPHP's built-in testing framework, highlighting its key features like unit and integration testing, and how it enhances application reliability through early bug detection and improved code quality.

How to Use ThinkPHP for Building Real-Time Stock Market Data Feeds?How to Use ThinkPHP for Building Real-Time Stock Market Data Feeds?Mar 18, 2025 pm 04:57 PM

Article discusses using ThinkPHP for real-time stock market data feeds, focusing on setup, data accuracy, optimization, and security measures.

What Are the Key Considerations for Using ThinkPHP in a Serverless Architecture?What Are the Key Considerations for Using ThinkPHP in a Serverless Architecture?Mar 18, 2025 pm 04:54 PM

The article discusses key considerations for using ThinkPHP in serverless architectures, focusing on performance optimization, stateless design, and security. It highlights benefits like cost efficiency and scalability, but also addresses challenges

How to Implement Service Discovery and Load Balancing in ThinkPHP Microservices?How to Implement Service Discovery and Load Balancing in ThinkPHP Microservices?Mar 18, 2025 pm 04:51 PM

The article discusses implementing service discovery and load balancing in ThinkPHP microservices, focusing on setup, best practices, integration methods, and recommended tools.[159 characters]

What Are the Advanced Features of ThinkPHP's Dependency Injection Container?What Are the Advanced Features of ThinkPHP's Dependency Injection Container?Mar 18, 2025 pm 04:50 PM

ThinkPHP's IoC container offers advanced features like lazy loading, contextual binding, and method injection for efficient dependency management in PHP apps.Character count: 159

How to Use ThinkPHP for Building Real-Time Collaboration Tools?How to Use ThinkPHP for Building Real-Time Collaboration Tools?Mar 18, 2025 pm 04:49 PM

The article discusses using ThinkPHP to build real-time collaboration tools, focusing on setup, WebSocket integration, and security best practices.

What Are the Key Benefits of Using ThinkPHP for Building SaaS Applications?What Are the Key Benefits of Using ThinkPHP for Building SaaS Applications?Mar 18, 2025 pm 04:46 PM

ThinkPHP benefits SaaS apps with its lightweight design, MVC architecture, and extensibility. It enhances scalability, speeds development, and improves security through various features.

How to Build a Distributed Task Queue System with ThinkPHP and RabbitMQ?How to Build a Distributed Task Queue System with ThinkPHP and RabbitMQ?Mar 18, 2025 pm 04:45 PM

The article outlines building a distributed task queue system using ThinkPHP and RabbitMQ, focusing on installation, configuration, task management, and scalability. Key issues include ensuring high availability, avoiding common pitfalls like imprope

See all articles

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

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.