Assalamualaikum Wr. Wb. Hello everybody...:D.
I published tutorial how to implementation captcha on Yii2, and then I will publish again my tutorial how to implementation google reCAPTCHA on Yii2 application with widget.
Fisrt, please run this code with composer :
php composer.phar require --prefer-dist "himiklab/yii2-recaptcha-widget" "*"
or open your composer.json file and to require section :
"himiklab/yii2-recaptcha-widget" : "*"
Run the composer update.
Second, Sign up for an reCAPTCHA API keys.
Now, you had site key and secret key.
The third, please open your LoginForm model class, and change with following code bellow :
Now, your Yii2 appliaction have been implemented google reCAPTCHA...:D. So good luck. Wassalamualaikum Wr. Wb.
I published tutorial how to implementation captcha on Yii2, and then I will publish again my tutorial how to implementation google reCAPTCHA on Yii2 application with widget.
Fisrt, please run this code with composer :
php composer.phar require --prefer-dist "himiklab/yii2-recaptcha-widget" "*"
or open your composer.json file and to require section :
"himiklab/yii2-recaptcha-widget" : "*"
Run the composer update.
Second, Sign up for an reCAPTCHA API keys.
Now, you had site key and secret key.
The third, please open your LoginForm model class, and change with following code bellow :
public function rules(){The fourth, open your login.php file in views/site directory and add the code bellow :
return [
[['username', 'password'], 'required'],
['rememberMe', 'boolean'],
['captcha',\himiklab\yii2\recaptcha\ReCaptchaValidator::className(), 'secret' => 'your screet code'],
['password', 'validatePassword'],
];
}
<?= $form->field($model, 'captcha')->widget(Now, we will trial the yii2basic application. Please open your browser and access this link "http://localhost/yii2basic/web/index.php?r=site/login"
\himiklab\yii2\recaptcha\ReCaptcha::className(),
['siteKey' => 'Your sitekey']
) ?>
Now, your Yii2 appliaction have been implemented google reCAPTCHA...:D. So good luck. Wassalamualaikum Wr. Wb.