After purchasing the plugin go to downloads page and download the plugin. After downloading, extract it. The folder structure and details about each file is explained below.
File or Folder Name | Description |
---|---|
Demo/ | Contains demo version with HTML form, javascript and php backend scripts. |
Documentation/ | Contains the documentation link |
iCaptcha/ | Contains the main source code |
config.php | Contains your site secret keys which can be generated from here |
index.php | Contains the HTML code of reCaptcha |
icaptcha.script.js | Contains the code which makes an AJAX "POST" request call to verify.php with param as reCaptcha token. |
verify.php | Contains the backend php script which makes call to google api to verify the token sent by frontend |
htdocs
folder of xampp or wamp or any other server to quickly test it. But make sure before that you generate keys and add it to config.php
file.
You can integrate the recaptcha code with any form or other elements for verification. Below are the steps to integrate:
Generate Site Keys:
config.php
fileImport scripts:
<!-- Google reCaptcha v2 script -->
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
<!-- iCaptcha Script -->
<script src="icaptcha.script.js"></script>
Add reCAPTCHA HTML
Add reCAPTCHA HTML code in present in index.php
file in any of your form or any place of your choice. You can learn more about data tag attributes from here here.
<div class="g-recaptcha"
data-sitekey="<?php echo CAPTCHA_SITE_KEY; ?>"
data-callback="recaptchaCheckedCb"
data-expired-callback="recaptchaExpireCb"
data-theme="light">
</div>
recaptchaCheckedCb
: This function runs when captcha is checked
recaptchaExpireCb
: This function runs when checked captcha is expired
Change the API end point of ajax call in icaptcha.script.js
$.ajax({
type: "POST", // Type of request
url: "http://localhost/iCaptcha/verify.php", // API endpoint
data: params, // params(captcha token)
...
...
The php script which verifies the token sent by front-end is present in verify.php
file. The php script makes a POST request to Google captcha verification API
The variable details is given below:
POST Parameter | Description |
---|---|
secret | Required. The shared key between your site and reCAPTCHA. |
response | Required. The user response token provided by the reCAPTCHA client-side integration on your site. |
remoteip | Optional. The user's IP address. |
Important links and other useful information which might be useful to make use of script more effectively.
- v1.0.0
- Initial Release