S B
S B

Reputation: 8394

captcha does not work on yii

User model:

public function rules()
{
    return array(
        ...
        array('verifyCode', 'captcha', 'on'=>'register'),
        ...
    );
}

UserController

public function actionRegister()
{
    $model=new User;
    if(isset($_POST['User']))
    {
        $model->attributes=$_POST['User'];
        if($model->save()){
             $this->redirect(array('login'));
        }
    }
    ...
    $this->render('register');
}

View - register.php

<?php $this->widget('CCaptcha'); ?>
            <div class="captcha"><?php echo CHtml::activeTextField( $model,'verifyCode', array('class'=>'captcha')); ?></div>
    <?php echo $form->error($model,'verifyCode'); ?>

This renders the captcha alright but the validation does not happen. What could be the problem?

Upvotes: 0

Views: 4357

Answers (1)

Related Questions