Codeigniter recaptcha form validation – Google recaptcha

Codeigniter recaptcha form validation – Google recaptcha

In this Post We Will Explain About is Codeigniter recaptcha form validation – Google recaptcha With Example and Demo.Welcome on – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to codeigniter recaptcha form validationExample

In this post we will show you Best way to implement Google New reCaptcha using PHP Codeigniter, hear for integrate google recaptcha with codeigniter validationwith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

First step : simple get an Google api key for your site from admin of the google, we must have google account simple ,and then go to this link below link and fill form some information like image

  Bash if else statement using Bash Scripting

Step Second : copy simple generated and then api key like this image simple images.

and then put recaptcha simple input tag into your form data then put your simple api code into it, and then put api here link above the some same file like this

<div class="g-recaptcha"></div>

List of all Google Adsense, VueJS, AngularJS, PHP, Laravel Examples.

Download Project Scripts

Step three : and then into your simple cI controller put this simple validation function

function live_captcha_validation() {
        $get_captcha = $this->input->post('g-recaptcha-response');
         $data_response = file_get_contents(" put here secret key here &response=" . $get_captcha . "&remoteip=" . $_SERVER['REMOTE_ADDR']);
        if ($data_response . 'success' == false) {
            return FALSE;
        } else {
            return TRUE;

or you can use curl if file_get_contents not supported by your hosting provider like this

  Check Uncheck All Checkbox using ReactJS

 function live_captcha_validation() {
        $valid_recaptcha = trim($this->input->post('g-recaptcha-response'));
        $userIp= $this->input->ip_address();
        $param_data = array(
            'secret' => "$secret",
            'response' => "$valid_recaptcha",
            'remoteip' =>"$userIp"

        $my_curl_live = curl_init();
        curl_setopt($my_curl_live, CURLOPT_URL, "");
        curl_setopt($my_curl_live, CURLOPT_POST, true);
        curl_setopt($my_curl_live, CURLOPT_POSTFIELDS, http_build_query($param_data));
        curl_setopt($my_curl_live, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($my_curl_live, CURLOPT_RETURNTRANSFER, true);
        $data_response = curl_exec($my_curl_live);
        $status= json_decode($data_response, true);
            return FALSE;
            return TRUE;

and Then put this simple validation some rule and text validation message

$this->form_validation->set_rules('g-recaptcha-response', 'here  live recaptcha validation', 'required|callback_live_captcha_validation');
$this->form_validation->set_message('live_captcha_validation', 'Please some check the here captcha form');


I hope you have Got What is Integrating Google’s reCaptcha in CodeIgniter’s form validation And how it works.I would Like to have FeadBack From My Blog( readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article( Are Most Always Welcome.

Related FAQ

Here are some more FAQ related to this Article:

  1.   Check WordPress Plugin Dependencies
  2.   Pagination with jQuery Ajax PHP and MySQL
  3.   VueJS json array object string parse Example
  4.   Laravel Update Multiple Records using Eloquent
  5.   Laravel 7 Custom Pagination View Example Tutorial
  6.   Codeigniter Form Validation with Google reCAPTCHA
  7.   Simple Vuejs Currency Converter Example
  8.   Magento 2 How to solve one or more indexers with Reindexing using Command
  9.   PHP Uploading Multiple Files to Amazon S3 Server
  10.   Bash if else statement using Bash Scripting

Leave a Reply

Your email address will not be published. Required fields are marked *