Search
 
SCRIPT & CODE EXAMPLE
 

PHP

google recaptcha varification in php 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

google recaptcha varification in php 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 :: workpress change page title from shortcode 
Php :: laravel search function 
Php :: CONVERTIR TABLEAU EN CHAINE DE CARACTÈRE PHP 
Php :: decode a nested JSON with php 
Php :: create qr code png image of 200*200 using phpqrcode 
Php :: laravel remove controller 
Php :: php enablem mod 
Php :: doctrine orm refresh 
Php :: $ whereis php terminal mac 
Php :: laravel test filter 
Php :: blade format date 
Php :: string concatenation in php 
Php :: shortcode wordpress form 
Php :: laravel collection splice 
Php :: enable socket in php 
Php :: autoloading classes 
Php :: php object to json 
Php :: Publish Spatie Laravel Permission 
Php :: add column migration laravel 8 
Php :: form submit self php isset 
Php :: compare key and one array 
Php :: mail laravel 
Php :: In PackageManifest.php line 122: Undefined index: name 
Php :: Best testing tools for php 
Php :: if else php 
Php :: heredoc 
Php :: laravel.log" could not be opened in append mode 
Php :: double in php 
Php :: php array form 
Php :: PHP create array of specified size 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =