Herecomes the our coding part, insert following part in header
<script src='https://www.google.com/recaptcha/api.js'></script>
For showing the recpatcha section, use the below html code. Complete the code by using your data site key.
<div class="g-recaptcha" data-sitekey="ENTER YOUR SITE KEY"></div>
Add the secret key in your controller with following code.
$recaptchaResponse = trim($this->input->post('g-recaptcha-response')); $secret='ENTER THE SECRET KEY'; $credential = array( 'secret' => $secret, 'response' => $this->input->post('g-recaptcha-response') ); $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($credential)); curl_setopt($verify, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($verify, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($verify); $status= json_decode($response, true); if($status['success']) { echo “sucesssâ€; } Else{ Echo “failâ€; }