这篇文章主要介绍了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下添加代码:
本例代码仅为主要功能简述,读者还可以根据自身项目需求进一步完善该程序代码,使其功能更具实用性。
,每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号