Yii Framework Forum: Captcha In Yii Framework Don't Appear (Show) - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Captcha In Yii Framework Don't Appear (Show) Rate Topic: -----

#1 User is offline   redjohn 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 10-January 13

Posted 10 January 2013 - 11:40 AM

what's wrong? Please help..

------Model--------

public $verifyCode;

public function rules()
{

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


public function attributeLabels()

{

return array('verifyCode'=>'Verification Code', );
}








--------Controller
public function actions(){
return array(

// captcha action renders the CAPTCHA image displayed on the user registration page

'captcha'=>array(

'class'=>'CCaptchaAction',

'backColor'=>0xFFFFFF,
),
);

}



public function accessRules()
{

return array(
array('allow', 'actions'=>array('create','update','captcha'),
'users'=>array('@'),),
);


}




-------------------View--------------

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

'id'=>'project-form',

'enableAjaxValidation'=>false,
));
?>


<?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(); ?>
0

#2 User is offline   alirz23 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 988
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 11 January 2013 - 04:43 AM

what error you get? can you paste you stacktrace
0

#3 User is offline   1cichy 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 24
  • Joined: 12-June 12
  • Location:Poland

Posted 11 January 2013 - 05:06 AM

This form is displaying only for authenticated users?
In rules you have:
return array(
array('allow', 'actions'=>array('create','update','captcha'),
'users'=>array('@'),),
);

0

#4 User is offline   redjohn 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 10-January 13

Posted 11 January 2013 - 11:52 AM

/* MOD: unnecessary quote removed */

Attached File(s)


0

#5 User is offline   Aneesh Asokan 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 240
  • Joined: 26-September 12

Posted 11 January 2013 - 12:29 PM

Check your controller action rules with this
public function accessRules() 
{
        return array('allow', 'actions' => array('captcha'), 'users' => array('*'));
}


try to change the '@' ('users' => array('*')) with '*'.

Thanks
Thanks
Aneesh.
0

#6 User is offline   redjohn 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 10-January 13

Posted 11 January 2013 - 12:49 PM

View PostRvr101, on 11 January 2013 - 12:29 PM, said:

Check your controller action rules with this
public function accessRules() 
{
        return array('allow', 'actions' => array('captcha'), 'users' => array('*'));
}


try to change the '@' ('users' => array('*')) with '*'.

Thanks

doesn't work
0

#7 User is offline   redjohn 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 10-January 13

Posted 11 January 2013 - 12:54 PM

View PostRvr101, on 11 January 2013 - 12:29 PM, said:

Check your controller action rules with this
public function accessRules() 
{
        return array('allow', 'actions' => array('captcha'), 'users' => array('*'));
}


try to change the '@' ('users' => array('*')) with '*'.

Thanks




http://freakshare.co...h2/999.rar.html

index.php?r=site/login -> work
index.php?r=users/create -> dont work
0

#8 User is offline   Aneesh Asokan 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 240
  • Joined: 26-September 12

Posted 11 January 2013 - 12:56 PM

Appear the same UI again..?

Is it work in your Yii application contact form..?
Thanks
Aneesh.
0

#9 User is offline   redjohn 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 10-January 13

Posted 11 January 2013 - 03:00 PM

View PostRvr101, on 11 January 2013 - 12:56 PM, said:

Appear the same UI again..?

Is it work in your Yii application contact form..?

captcha for contact form works, but I want captcha in other place
0

#10 User is offline   Aneesh Asokan 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 240
  • Joined: 26-September 12

Posted 11 January 2013 - 11:28 PM

Add the following in the controller
        public function actions()
	{
		return array(
			// captcha action renders the CAPTCHA image displayed on the contact page
			'captcha'=>array(
				'class'=>'CCaptchaAction',
				'backColor'=>0xFFFFFF,
			),
			
		);
	}


In model
a. Define the variable
public $verifyCode;

b. Add variable in access rules
        public function rules()
	{
		return array(
			
                        array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements()),
		);
	}


In the view file
<?php if(CCaptcha::checkRequirements()): ?>
	<div class="row"><tr>
                
                
		<div>
                    <?php echo $form->labelEx($model,'verifyCode'); ?>
                    <?php $this->widget('CCaptcha'); ?>
                    <?php echo $form->textField($model,'verifyCode'); ?>
                    <?php echo $form->error($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>
		
	</div>
	<?php endif; ?>


Thanks
Thanks
Aneesh.
0

#11 User is offline   redjohn 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 10-January 13

Posted 12 January 2013 - 06:14 AM

View PostRvr101, on 11 January 2013 - 11:28 PM, said:

Add the following in the controller
        public function actions()
	{
		return array(
			// captcha action renders the CAPTCHA image displayed on the contact page
			'captcha'=>array(
				'class'=>'CCaptchaAction',
				'backColor'=>0xFFFFFF,
			),
			
		);
	}


In model
a. Define the variable
public $verifyCode;

b. Add variable in access rules
        public function rules()
	{
		return array(
			
                        array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements()),
		);
	}


In the view file
<?php if(CCaptcha::checkRequirements()): ?>
	<div class="row"><tr>
                
                
		<div>
                    <?php echo $form->labelEx($model,'verifyCode'); ?>
                    <?php $this->widget('CCaptcha'); ?>
                    <?php echo $form->textField($model,'verifyCode'); ?>
                    <?php echo $form->error($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>
		
	</div>
	<?php endif; ?>


Thanks

doesn't work...
0

#12 User is offline   gaz 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 16
  • Joined: 03-January 13

Posted 11 March 2013 - 06:17 AM

Hi there,

I am experiencing a similar problem, with the captcha image not displaying on the host server, and yet on my localhost the captcha image is visible. I have tried the forums to get some help but I am stuck. I've tried changing all the files as displayed on this and other posts, but to no avail.

I am also experiencing issues when I click on 'Get a new code' on both localhost and on the server. The below output is shown on a blank white screen:

{"hash1":651,"hash2":651,"url":"\/index.php\/site\/captcha?v=513d69a205490"}

I don't know if this problem is related to the previous issue? All I know is that I have probably need to do some more reading about 'routing'.

If anyone can point me in the right direction it will be much appreciated. Thank you.

Yii 1.1.13
0

#13 User is offline   faridplus 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 93
  • Joined: 28-March 12

Posted 14 March 2013 - 02:25 PM

View Postgaz, on 11 March 2013 - 06:17 AM, said:

Hi there,

I am experiencing a similar problem, with the captcha image not displaying on the host server, and yet on my localhost the captcha image is visible. I have tried the forums to get some help but I am stuck. I've tried changing all the files as displayed on this and other posts, but to no avail.....



make sure that GD (GD2) extension is enabled in the php.ini config file.
What you give is what you get (WYGIWYG)

If you liked my post, just give it a +1. that's all!
0

#14 User is offline   gaz 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 16
  • Joined: 03-January 13

Posted 14 March 2013 - 08:51 PM

View Postfaridplus, on 14 March 2013 - 02:25 PM, said:

make sure that GD (GD2) extension is enabled in the php.ini config file.


Hi faridplus,

thanks for your help.

The server is configured for captcha according to the Yii's functional testsite file (see attached image).
Attached File  Screen shot 2013-03-09 at 2.36.39 PM.png (17.4K)
Number of downloads: 10
So I am assuming that the host server php.ini file enables GD functionality. I'm in the process of upgrading to a new host environment in the next few days, so I will see if that helps.

I haven't quite worked out why on clicking the link "Get new code" generates this output though:
Attached File  Screen shot 2013-03-15 at 12.45.56 PM.png (20.11K)
Number of downloads: 9

Cheers
0

#15 User is offline   faridplus 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 93
  • Joined: 28-March 12

Posted 15 March 2013 - 02:52 AM

View Postgaz, on 14 March 2013 - 08:51 PM, said:

Hi faridplus,

thanks for your help.

The server is configured for captcha according to the Yii's functional testsite file (see attached image).
Attachment Screen shot 2013-03-09 at 2.36.39 PM.png
So I am assuming that the host server php.ini file enables GD functionality. I'm in the process of upgrading to a new host environment in the next few days, so I will see if that helps.

I haven't quite worked out why on clicking the link "Get new code" generates this output though:
Attachment Screen shot 2013-03-15 at 12.45.56 PM.png

Cheers


Hi, this time use Firebug and look at Net panel when you click on the 'Get a new code'. it should display 2 separate requests: one for getting that JSON object ({"hash" : ... , "url" : ...}) and another for loading the actual image. If any error happens, Firebug usually reports it.
What you give is what you get (WYGIWYG)

If you liked my post, just give it a +1. that's all!
0

#16 User is offline   gaz 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 16
  • Joined: 03-January 13

Posted 17 March 2013 - 10:32 PM

View Postfaridplus, on 15 March 2013 - 02:52 AM, said:

Hi, this time use Firebug and look at Net panel when you click on the 'Get a new code'. it should display 2 separate requests: one for getting that JSON object ({"hash" : ... , "url" : ...}) and another for loading the actual image. If any error happens, Firebug usually reports it.


Thanks faridplus for you time.

I get no error when I click on 'Get new code' when I view the result on Firebug and the Net panel.

Attached File  Screen shot 2013-03-16 at 3.01.29 PM.png (21.33K)
Number of downloads: 9

However, when I go to the index page of the web site I get this result:

Attached File  Screen shot 2013-03-16 at 3.00.49 PM.png (26.25K)
Number of downloads: 10

Something is amiss with either my setup on the host server or my config files.

---------------------------------------------------------------------
Update:

To fix the issue regarding the missing 'captcha' image, I contacted my host provider to comment out the line in the php.ini file -

;error_reporting = E_ALL & ~E_DEPRECATED

and to turn 'safe_mode' to 'off'.

cheers
Gaz
0

#17 User is offline   Musafir 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 24-December 13

Posted 25 December 2013 - 05:14 PM

Dear all..

I wanted to add captchaExtended-1.0.2 because captcha was not working,,,
I install that and follow instructions but didn't work.
kindly guide me . I am usning (yii-1.1.14.f0fee9)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users