is anyone ever use Yii 1.1.6 especially using captcha on the login form.
I read a few documentation that has a discussion about captcha, especially I follow this instruction.
I don’t know why my captcha not shown on my login form.
this is my models
class LoginForm extends CFormModel
{
public $username;
public $password;
public $rememberMe;
public $verifyCode;
private $_identity;
public function rules()
{
return array(
// username and password are required
array('username, password', 'required'),
// rememberMe needs to be a boolean
array('rememberMe', 'boolean'),
// password needs to be authenticated
array('password', 'authenticate'),
//verifycode needs to be entered correctly
array('verifyCode', 'captcha', 'allowEmpty' => !CCaptcha::checkRequirements()),
);
}
public function attributeLabels()
{
return array(
'username'=>'Email',
'password'=>'Password',
'verifyCode'=>'Verify code',
'rememberMe'=>'Remember me',
);
}
and this is my controllers
class SiteController extends Controller
{
public function actions()
{
return array(
// captcha action renders the CAPTCHA image displayed on the contact page
'captcha' => array(
'class' => 'CCaptchaAction',
'backColor' => 0xFFFFFF,
),
);
},
public function actionLogin($next=false)
{
$model=new LoginForm();
// collect user input data
if(isset($_POST['LoginForm']))
{
$model->attributes=$_POST['LoginForm'];
$model->verifyCode=$_POST['LoginForm']['verifyCode'];
// validate user input and redirect to the home page if valid
if($model->validate() && $model->login()) {
$this->redirect($next === false ? Yii::app()->user->returnUrl : $next);
}
}
// display the login form
$this->renderPartial('login',array('model'=>$model));
}
}
and this is my view site/login.php
<div class="form-group has-feedback">
<?php if (CCaptcha::checkRequirements()) : ?>
<div class="row">
<?php echo $form->labelEx($model, 'verifyCode'); ?>
<div>
<?php $this->widget('CCaptcha'); ?>
<?php echo $form->textField($model, 'verifyCode'); ?>
</div>
<div class="hint">Please enter the letters as they are shown in the image above.
Letters are not case-sensitive.
</div>
<?php echo $form->error($model, 'verifyCode'); ?>
</div>
anyone can help me with this issue?
Please.
Thank you, everyone.