davidvandertuijn/recaptcha

3.0 2022-03-07 21:23 UTC

This package is auto-updated.

Last update: 2024-10-29 13:30:27 UTC


README

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