Search
 
SCRIPT & CODE EXAMPLE
 

PHP

how to integrate google reCAPTCHA in codeigniter?

/**
	 * VALIDATE RECAPTHCA FUNCTION IS RESPONSIBLE FOR VALIDATING THE REACAPTCHA
	 *
	 * @return boolean
	 */
	function validate_captcha()
	{
		$recaptcha = trim($this->input->post('g-recaptcha-response'));
		$userIp = $this->input->ip_address();
		$secret = get_system_settings('recaptcha_secretkey'); //key
		$data = array(
			'secret' => "$secret",
			'response' => "$recaptcha",
			'remoteip' => "$userIp"
		);

		$verify = curl_init();
		curl_setopt($verify, CURLOPT_URL, "https://www.google.com/recaptcha/api/siteverify");
		curl_setopt($verify, CURLOPT_POST, true);
		curl_setopt($verify, CURLOPT_POSTFIELDS, http_build_query($data));
		curl_setopt($verify, CURLOPT_SSL_VERIFYPEER, false);
		curl_setopt($verify, CURLOPT_RETURNTRANSFER, true);
		$response = curl_exec($verify);
		$status = json_decode($response, true);

		if (empty($status['success'])) {
			return FALSE;
		} else {
			return TRUE;
		}
	}
Comment

PREVIOUS NEXT
Code Example
Php :: php website templates free download with database 
Php :: laravel edit method 
Php :: wordpress theme basics including CSS and js 
Php :: overloading and overriding in php 
Php :: expose loading laravel 
Php :: causes of class not found in laravel 
Php :: difference between array_merge and + 
Php :: Update Data Multiple Columns MySql Database Table PHP Function 
Php :: php convert accented characters to html entities 
Php :: laravel faker value or null 
Php :: php 8 loadmodule 
Php :: cakephp find_in_set 
Php :: dependency injection php 
Php :: php += 
Php :: page.php woocommerce 
Php :: echo require php 
Php :: php password_hash 
Php :: unravel_index numpy 
Php :: adding two numbers in php 
Php :: date comparison function in php 
Php :: how to add an array into an associative array in php 
Php :: docker compose php 
Php :: logout all users laravel 8 
Php :: find_in_set in laravel 
Php :: if php 
Php :: error handling in laravel 
Php :: how to create object in php 
Php :: PHP Notice: Trying to get property of non-object 
Php :: php array merge without array_merge 
Php :: download file from s3 using laravel 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =