Not Able to generate captcha image

I am not able to generate my captcha image, i am posting my form and model class below

I have my form as below




<?php $form=$this->beginWidget('CActiveForm', array(

	'id'=>'user-profile-form',

	'enableAjaxValidation'=>false,

        'enableClientValidation'=>true,

        'clientOptions'=>array(

		'validateOnSubmit'=>true,

	),

)); ?>


	<p class="note">Fields with <span class="required">*</span> are required.</p>


	<?php echo $form->errorSummary($model); ?>


	<div class="row">

		<?php echo $form->labelEx($model,'email'); ?>

		<?php echo $form->textField($model,'email',array('size'=>60,'maxlength'=>70)); ?>

		<?php echo $form->error($model,'email'); ?>

	</div>


	<div class="row">

		<?php echo $form->labelEx($model,'password'); ?>

		<?php echo $form->passwordField($model,'password',array('size'=>60,'maxlength'=>128)); ?>

		<?php echo $form->error($model,'password'); ?>

	</div>


        <div class="row">

		<?php echo $form->labelEx($model,'confirm_password'); ?>

		<?php echo $form->passwordField($model,'confirm_password',array('size'=>60,'maxlength'=>128)); ?>

		<?php echo $form->error($model,'confirm_password'); ?>

	</div>


        <div class="row">

		<?php echo $form->labelEx($model,'realname'); ?>

		<?php echo $form->textField($model,'realname',array('size'=>60,'maxlength'=>70)); ?>

		<?php echo $form->error($model,'realname'); ?>

	</div>


        <div class="row">

		<?php echo $form->labelEx($model,'role_id'); ?>

		<?php echo $form->dropDownList($model,'role_id',$list_roles); ?>

		<?php echo $form->error($model,'role_id'); ?>

	</div>


        <?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.

		<br/>Letters are not case-sensitive.</div>

		<?php echo $form->error($model,'verifyCode'); ?>

	</div>

	<?php endif; ?>


	<div class="row buttons">

		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>

	</div>


<?php $this->endWidget(); ?>



And my model class goes below




class UserProfile extends CActiveRecord

{

        public $confirm_password;

        public $verifyCode;


	public static function model($className=__CLASS__)

	{

		return parent::model($className);

	}

        public function rules()

	{

		return array(

			array('email, password, confirm_password, realname, created_on, created_by', 'required'),

			array('created_on, lastvisit, created_by, role_id, status', 'numerical', 'integerOnly'=>true),

			array('email, realname', 'length', 'max'=>70, 'min' => 7, 'message' => 'Incorrect Email (minimal length 7 symbols).'),

			array('password', 'length', 'max'=>128,'min' => 7,'message' => 'Incorrect Password (minimal length 7 symbols).'),

                        array('confirm_password', 'compare', 'compareAttribute'=>'password', 'message' => 'Retype Password is incorrect.'),

                        array('email', 'unique', 'message' => 'This user\'s email address already exists.'),

                        array('realname', 'match', 'pattern' => '/^[A-Za-z0-9_]+$/u','message' => 'Incorrect symbols (A-z0-9).'),

                        array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements()),

			array('id, email, realname, created_on, lastvisit, created_by, role_id, status', 'safe', 'on'=>'search'),

		);

	}

}



could some one help me out on this.

Does your controller have a captcha action? This is need for the captcha to work.

Put something like this in the controller that renders the view:




public function actions()

{

	return array(

		'captcha'=>array(

			'class'=>'CCaptchaAction',

			'backColor'=>0xFFFFFF,

			'foreColor'=>0x000000,

		),

	);

}



If you use accessRules on that controller, make sure everyone has access to that captcha action




array('allow',

	'actions'=>array('forgotpass'),

	'users'=>array('?'),

)



HTH :)

in your validation rules you should use this [color="#000000"][font=“monospace”][size=“2”]array[/size][/font][/color][color="#666600"][font=“monospace”][size=“2”]([/size][/font][/color][color="#008800"][font=“monospace”][size=“2”]‘verifyCode’[/size][/font][/color][color="#666600"][font=“monospace”][size=“2”],[/size][/font][/color][color="#000000"] [/color][color="#008800"][font=“monospace”][size=“2”]‘captcha’[/size][/font][/color][color="#666600"][font=“monospace”][size=“2”],[/size][/font][/color][color="#000000"] [/color][color="#008800"][font=“monospace”][size=“2”]‘allowEmpty’[/size][/font][/color][color="#666600"][font=“monospace”][size=“2”]=>![/size][/font][/color][color="#000000"][font=“monospace”][size=“2”]extension_loaded[/size][/font][/color][color="#666600"][font=“monospace”]size=“2”), instead of your existing code also you should check requirements with yii Requirements checker for GD2 library in your server.[/size][/color][/font]