mrkarma4ya
1 month ago
267
3
Laravel

Looking for a good tutorial on implementing recaptcha v3 on Laravel 6

Posted 1 month ago by mrkarma4ya

I've been looking for a good tutorial on the topic, but I haven't found any that is beginner'friendly.

I'm looking for one that teaches how to install and implement Google Recaptcha using this package: https://github.com/google/recaptcha

Most tutorials are just blocks of code saying - copy this into that, but I don't know what they do at all.

What I've done:

Generated the site and secret keys and put them in my env file.

This is in my header:

<script src="https://www.google.com/recaptcha/api.js?render={{ env('CAPTCHA_SITE_KEY') }}"></script>

This is in footer:

<script>
        grecaptcha.ready(function() {
    grecaptcha.execute('{{ env('CAPTCHA_SITE_KEY') }}', {action: 'contact-us'}).then(function(token) {
       if(token){
           document.getElementById('recaptcha').value = token;
       }
    });
});
    </script>

And this is the field in contact form:

<input type="hidden" name="recaptcha" id="recaptcha">

After this, I'm completely lost.

Please sign in or create an account to participate in this conversation.