Skip to content
Advertisement

PHP – Validate the recaptcha v2 response

JavaScript

Returns:

Notice: Undefined index: g-recaptcha-response in /var/www/clients/qmax/app/controllers/job_application_controller.php on line 114 { “success”: false, “error-codes”: [ “missing-input-response” ] }

JavaScript

Returns:

Notice: Trying to get property of non-object in /var/www/clients/qmax/app/controllers/job_application_controller.php on line 119

I just need to get the “success” object, then I can test if it is True OR False and I am done.

Advertisement

Answer

Remove this line:

JavaScript

Then you need to decode the json by Google like so:

JavaScript

Then just check with if/else:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement