-
Notifications
You must be signed in to change notification settings - Fork 1
Tutorials
Denys Xavier edited this page Apr 22, 2015
·
2 revisions
Assuming your site has only one file named index.php, and you have downloaded the project ZIP file and extracted its folder "reCaptchaV2" into your website root folder, you will have this structure:
- /
- reCaptchaV2/
- en.txt
- reCaptchaV2.php
- reCaptchaV2/
- index.php
In every script where you want to use ReCaptchaV2, you must include reCaptchaV2.php and create a new instance of ReCaptchaV2 using both keys provided by Google.
<?php
require_once("reCaptchaV2/reCaptchaV2.php");
$siteKey = "";
$secretKey = "";
$reCaptcha = new ReCaptchaV2($siteKey, $secretKey);
?>
First, place the script tag referring to Google API in the head tag of your html page, like this:
<head>
<!-- Other head tags -->
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
</head>
Then, you can use getWidget method from your ReCaptchaV2 object to get the necessary markup for the new "No Captcha" Widget. Then, you just need to print the returned string where you want the widget to appear.
<form action="?" method="POST">
<?php echo ($reCaptcha->getWidget()); ?> <br/>
<input type="submit" value="Submit">
</form>