这篇文章主要介绍了yii实现创建验证码的方法,很常见的一类功能,需要的朋友可以参考下
本文以实例形式讲述了yii创建验证码的方法,具体步骤如下所示:
一、在SiteController action()下添加如下代码:
return array( // captcha action renders the CAPTCHA image displayed on the contact page 'captcha'=>array( 'class'=>'CCaptchaAction', 'backColor'=>0xFFFFFF, ), // page action renders "static" pages stored under 'protected/views/site/pages' // They can be accessed via: index.php?r=site/page&view=FileName 'page'=>array( 'class'=>'CViewAction', ), );
二、(1)在LoginForm model rules()下添加代码:
//captche class needed array('verifyCode', 'captcha','allowEmpty'=>!CCaptcha::checkRequirements()),
(2)LoginForm model下添加属性:
public $verifyCode;
三、在ContactForm model rules()下添加代码:
// verifyCode needs to be entered correctly array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements()),
四、在login view下添加代码:
本例代码仅为主要功能简述,读者还可以根据自身项目需求进一步完善该程序代码,使其功能更具实用性。
,
Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Zend Studio 13.0.1
Powerful PHP integrated development environment

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.

Dreamweaver CS6
Visual web development tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.