Codeigniter Form Validation with Google reCAPTCHA

Codeigniter JavaScript jQuery Programming Technology

Codeigniter Form Validation with Google reCAPTCHA

In this Post We Will Explain About is Codeigniter Form Validation with Google reCAPTCHA With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Integrate reCAPTCHA in Codeigniter Tutorial Example

In this post we will show you Best way to implement recaptcha example with codeigniter validation, hear for Integrating Google’s reCaptcha in CodeIgniter’s form validation with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

1 Phase # Get an api key for Web-site from google

integrate_codeigniter_recaptcha_with_codeigniter_validation, We must have google gmail account ,go to this simple link and fill the full form like image. google recaptcha with codeigniter

https://www.google.com/recaptcha/admin

2 Phase # copy generated api key/h3>

And then we put codeigniter recaptcha input into simple your HTML form and then put your google api source code into it,After that put api link above the same php file.

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

3 Phase # Put CI controller put this simple validation methods

function captcha_validation_google() {
    $google_captcha = $this->input->post('g-recaptcha-response');
    $response_google = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=Google_Your_secreate_key_here &response=" . $google_captcha . "&remoteip=" . $_SERVER['REMOTE_ADDR']);
    if ($response_google . 'success' == false) {
        return FALSE;
    } else {
        return TRUE;
    }
}

after thet you can simple use curl if all the data content php function Like as a file_get_contents not supported by your any linux or more hosting provider simple like this example

function captcha_validation_google() {
    $recaptcha_google = trim($this->input->post('g-recaptcha-response'));
    $userIp_google= $this->input->ip_address();
    // put your google secret key hear
    $google_secret='put-your-secret-key-hear';
    $data_google_captcha = array(
        'secret' => "$google_secret",
        'response' => "$recaptcha_google",
        'remoteip' =>"$userIp_google"
    );
 
    $live_captcha_verfy = curl_init();
    curl_setopt($live_captcha_verfy, CURLOPT_URL, "https://www.google.com/recaptcha/api/siteverify");
    curl_setopt($live_captcha_verfy, CURLOPT_POST, true);
    curl_setopt($live_captcha_verfy, CURLOPT_POSTFIELDS, http_build_query($data_google_captcha));
    curl_setopt($live_captcha_verfy, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($live_captcha_verfy, CURLOPT_RETURNTRANSFER, true);
    $captcha_response = curl_exec($live_captcha_verfy);
    $status_capcha= json_decode($captcha_response, true);
    if(empty($status_capcha['success'])){
        return FALSE;
    }else{
        return TRUE;
    }
}

And Then create this simple ci validation rule as well as validation message

$this->form_validation->set_rules('g-recaptcha-response', 'recaptcha validation', 'required|callback_validate_captcha');
$this->form_validation->set_message('captcha_validation_google', 'Again Please check your Google the the captcha form');

You are Most welcome in my youtube Channel Please subscribe my channel. and give me FeedBack.
More Details……
Angularjs Example

Example

I hope you have Got What is CodeIgniter 3.0 Form Validation BotDetect CAPTCHA Example And how it works.I would Like to have FeedBack From My Blog(Pakainfo.com) readers.Your Valuable FeedBack,Any Question,or any Comments about This Article(Pakainfo.com) Are Most Always Welcome.


Related FAQ

Here are some more FAQ related to this Article:

  1.   Stripe API subscriptions with plan coupon and discounts using PHP
  2.   Create Canned Responses using PHP Auto-Replies
  3.   VueJs Dynamic Class and Style Bindings
  4.   Radio button validation in jquery Example
  5.   Laravel Remove Public From URL Steps
  6.   Codeigniter recaptcha form validation - Google recaptcha
  7.   Laravel Soft Delete Example Tutorial From Scratch
  8.   PHP Ajax Display Dynamic MySQL Data in Bootstrap Modal
  9.   create custom seo friendly url in vuejs Example
  10.   Woocommerce list product attributes

Leave a Reply

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