The repo includes a complete sample code of how server-side & client-side Google reCATPCHA V2 validations work.
$ git clone https://github.com/Tes3awy/recaptcha-vanilla-php.git
$ cd recaptcha-vanilla-php
$ code . # Only if you are using VSCode
To begin with, you MUST provide both sitekey
and secretkey
in environment.php
file. These keys are provided when you create a reCAPTCHA V2 Checkbox.
It's a best practice approach to add those keys in environment variables as no one should have access to your
secretkey
.
data-sitekey="<SITE_KEY>" (Required)
data-theme="<THEME>" (Optional. Allowed values: "light" or "dark". Default: `light`)
data-size="<SIZE>" (Optional. Allowed values: "normal" or "compact". Default: `normal`)
data-callback="<CALLBACK_FUNCTION>" (Optional)
data-expired-callback="<EXPIRY_CALLBACK_FUNCTION>" (Optional)
data-error-callback="<ERROR_CALLBACK_FUNCTION>" (Optional)
I used Bootstrap v5.2.3 as the front-end library. And the
zephyr.min.css
was downloaded from Bootswatch (Zephyr Theme)
I made a tutorial about the server-side validation on . Grab your cup of coffee and enjoy 😉
You can also watch the client-side validation tutorial on
For reference, please visit Google reCAPTCHA Developers Guide.