Skip to content

davidvandertuijn/recaptcha

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

reCAPTCHA

Total Downloads Latest Stable Version License

reCAPTCHA

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.

"Buy Me A Coffee"

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
    }
}