Google Recaptcha in CodeIgniter

It is one of the major discussed question, how we can use google recaptcha in codeigniter.First we should need a google account to start. Login the corresponding gmail and access from your browser. Next you have to register the domain. After that you will get a site key and secret key.

Herecomes the our coding part, insert following part in header

<script src=''></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, "");
                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);
			 echo “sucesss”;
			  Echo “fail”;