0% found this document useful (0 votes)
5 views1 page

61 e 12 Ae 46 Ebe 4

The document contains a PHP function that verifies Google reCAPTCHA responses using cURL to send a request to the Google API. If the verification fails, it redirects the user to the checkout page with an error message. Additionally, it includes HTML code for rendering the reCAPTCHA widget on a form.

Uploaded by

Sheikh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

61 e 12 Ae 46 Ebe 4

The document contains a PHP function that verifies Google reCAPTCHA responses using cURL to send a request to the Google API. If the verification fails, it redirects the user to the checkout page with an error message. Additionally, it includes HTML code for rendering the reCAPTCHA widget on a form.

Uploaded by

Sheikh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

function reCaptcha($recaptcha){

$secret = "6LcU1uQdAAAAANTEef94SXIqh3pYljd9UoKWFPpu";
$ip = $_SERVER['REMOTE_ADDR'];

$postvars = array("secret"=>$secret, "response"=>$recaptcha, "remoteip"=>$ip);


$url = "https://www.google.com/recaptcha/api/siteverify";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postvars);
$data = curl_exec($ch);
curl_close($ch);

return json_decode($data, true);


}

$recaptcha = $request['g-recaptcha-response'];
$res = $this->reCaptcha($recaptcha);

if(!$res['success']){

return redirect('checkout')->with('error', 'Please check the


recaptcha');
exit;
// Error
}

<div class="form-group text-left">


<div class="g-recaptcha brochure__form__captcha" data-
sitekey="6LcU1uQdAAAAAH2KrTLpwhxJxWjnvHlZ--aL1D3k">
</div>
</div>

You might also like