In my contact page captcha not working after hosting…but in localhost works perfectly…
after hosting the captcha and the corresponding error message is missing…what i do…?
anyone can help me…please…?
my siteContrioller
public function actions()
{
return array(
// captcha action renders the CAPTCHA image displayed on the contact page
'captcha'=>array(
'class'=>'CCaptchaAction',
'backColor'=>0xFFFFFF,
),
public function actionContact()
{
$model=new ContactForm;
if(isset($_POST['ContactForm']))
{
$model->attributes=$_POST['ContactForm'];
if($model->validate())
{
$model->createContact();
$name='=?UTF-8?B?'.base64_encode($model->name).'?=';
$message='=?UTF-8?B?'.base64_encode($model->message).'?=';
$headers="From: $name <{$model->email}>\r\n".
"Reply-To: {$model->email}\r\n".
"MIME-Version: 1.0\r\n".
"Content-Type: text/plain; charset=UTF-8";
mail(Yii::app()->params['adminEmail'],$message,$model->body,$headers);
Yii::app()->user->setFlash('contact','Thank you for contacting us. We will respond to you as soon as possible...');
$this->refresh();
}
}
$this->render('contact',array('model'=>$model));
}
public function accessRules()
{
return array('allow', 'actions' => array('captcha'), 'users' => array('*'));
}
}
my ContactForm.php
public function rules()
{
return array(
// name, email, message are required
array('name, email, message', 'required'),
// email has to be a valid email address
array('email', 'email'),
// verifyCode needs to be entered correctly
array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements()),
);
}
public function attributeLabels()
{
return array(
'verifyCode'=>'Verification Code',
);
}
contact.php
<?php if(CCaptcha::checkRequirements()): ?>
<div class="form-group">
<?php echo $form->labelEx($model,'verifyCode'); ?>
<div>
<?php $this->widget('CCaptcha'); ?>
<?php echo $form->textField($model,'verifyCode',array('class'=>'captcha-control')); ?>
</div>
<?php echo $form->error($model,'verifyCode'); ?>
</div>
<?php endif; ?>