PHP code example of wendrowycz / zf1-recaptcha-2

1. Go to this page and download the library: Download wendrowycz/zf1-recaptcha-2 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/ */

    

wendrowycz / zf1-recaptcha-2 example snippets



$this->view->headScript()->appendFile('//www.google.com/recaptcha/api.js'); 
$this->view->addHelperPath(APPLICATION_PATH . 'Wendrowycz', 'Wendrowycz');

 $this->addPrefixPath('Wendrowycz\\Form\\Element', APPLICATION_PATH . '/../vendor/wendrowycz/zf1-recaptcha-2/src/Wendrowycz/Form/Element', Zend_Form::ELEMENT);
 $this->addElementPrefixPath('Wendrowycz\\Validate\\', APPLICATION_PATH . '/../vendor/wendrowycz/zf1-recaptcha-2/src/Wendrowycz/Validate/', Zend_Form_Element::VALIDATE);




// create your element and pass through your site key and secret key
$this->addElement('Recaptcha', 'g-recaptcha-response', [
    'siteKey'   => Zend_Registry::get('application')->recaptcha->sitekey,
    'secretKey' => Zend_Registry::get('application')->recaptcha->secretkey,
]);


if($form->isValid($_POST)) {
	$values = $form->getValues();
	unset($values['g-recaptcha-response']);
	// Your business logic must be here
}