davidvandertuijn / recaptcha
reCAPTCHA
Installs: 2 465
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=7.1.0
This package is auto-updated.
Last update: 2024-10-29 13:30:27 UTC
README
reCAPTCHA is an advanced security tool designed to protect websites from automated bots and malicious activities. By implementing reCAPTCHA, website owners can ensure that their online platforms remain secure while providing a user-friendly experience for legitimate users.
Install
composer require davidvandertuijn/recaptcha
Usage
use Davidvandertuijn\Recaptcha;
Register your site
reCAPTCHA: Easy on Humans, Hard on Bots
Add script -tag
<script src="//www.google.com/recaptcha/api.js"></script>
Add div -tag within <form>
... </form>
<div class="g-recaptcha" data-sitekey="your-sitekey-here"></div>
Verify
if ($_SERVER['REQUEST_METHOD'] == 'POST') { $recaptcha = new Recaptcha; $recaptcha->setSecret('your-secret-key-here'); $recaptcha->setResponse($_POST['g-recaptcha-response']); $recaptcha->setRemoteIp($_SERVER['REMOTE_ADDR']); if (!$recaptcha->verify()) { // false } else { // true } }