First off, we need to register our site in Google reCAPTCHA Admin and gain usage keys. When you add your site, also add localhost
in the list of domains, this will allow you to use the same key for development.
Once you submit these details, you should see two keys generated for your domain. One is the SITE KEY
which is used in the front-end and the other is the SECRET KEY
for usage in the server.
The front-end setup is pretty simple. Choose the page in which you want to implement reCAPTCHA, in my case I have a contact form on a page.
The below code shows a contact form with a hidden input named recaptcha
(it can be any name). Then at the end of that page add the reCAPTCHA’s JS library and once it’s ready we get a token and set it to the recaptcha
input.
#web dev #php tutorial #api integration #laravel tutorial #recaptcha #web applications