1. Go to this page and download the library: Download cakephp-fr/recaptcha library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cakephp-fr / recaptcha example snippets
return [
.... (other configs before)
'Recaptcha' => [
// Register API keys at https://www.google.com/recaptcha/admin
'sitekey' => 'your-sitekey',
'secret' => 'your-secret',
// reCAPTCHA supported 40+ languages listed
// here: https://developers.google.com/recaptcha/docs/language
'lang' => 'en',
// either light or dark
'theme' => 'light',
// either image or audio
'type' => 'image',
// either normal or compact
'size' => 'normal'
]
]
public function initialize() {
parent::initialize();
if ($this->request->getParam('action') === 'contact') {
$this->loadComponent('Recaptcha.Recaptcha');
}
}
public function contact() {
if ($this->request->is('post')) {
if ($this->Recaptcha->verify()) {
// Here you can validate your data
if (!empty($this->request->getData())) {
$this->Flash->success(__('We will get back to you soon.'));
return $this->redirect($this->referer());
} else {
$this->Flash->error(__('There was a problem submitting your form.'));
}
} else {
// You can debug developers errors with
// debug($this->Recaptcha->errors());
$this->Flash->error(__('Please check your Recaptcha Box.'));
}
}
}
<?= $this->Form->create()
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.