PHP code example of holduix / recaptcha

1. Go to this page and download the library: Download holduix/recaptcha library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

holduix / recaptcha example snippets




use Holduix\Component\reCAPTCHA;

$reCAPTCHA = new reCAPTCHA('your-site-key', 'your-secret-key', 'v2'); // or 'v3' for reCAPTCHA v3



use Holduix\Component\reCAPTCHA;

$reCAPTCHA = new reCAPTCHA();
$reCAPTCHA->setSiteKey('your-site-key');
$reCAPTCHA->setSecretKey('your-secret-key');
$reCAPTCHA->setVersion('v2'); // or 'v3' for reCAPTCHA v3

echo $reCAPTCHA->getScript();

echo $reCAPTCHA->getHtml();

if ($reCAPTCHA->isValid($_POST['g-recaptcha-response'])) {
    // Le captcha est valide
    echo "Captcha valide !";
} else {
    // Afficher les erreurs
    var_dump($reCAPTCHA->getErrorCodes());
}

echo $reCAPTCHA->getScript();

echo $reCAPTCHA->getHtml();

if ($reCAPTCHA->isValid($_POST['g-recaptcha-response'])) {
    // Le captcha est valide
    echo "Captcha valide !";
} else {
    // Afficher les erreurs
    var_dump($reCAPTCHA->getErrorCodes());
}

$reCAPTCHA->setTheme('dark');

$reCAPTCHA->setLanguage('fr'); // Français

$reCAPTCHA->setType('audio');

$reCAPTCHA->setSize('compact');

$reCAPTCHA->setScoreThreshold(0.7); // Custom Threshold


olduix\Component\reCAPTCHA;

$reCAPTCHA = new reCAPTCHA('your-site-key', 'your-secret-key', 'v2');
$reCAPTCHA->setTheme('dark');
$reCAPTCHA->setLanguage('fr');


olduix\Component\reCAPTCHA;

$reCAPTCHA = new reCAPTCHA('your-site-key', 'your-secret-key', 'v3');
$reCAPTCHA->setScoreThreshold(0.7); // Seuil personnalisé