php – How do I make a reCAPTCHA check?


How to check whether the user passed the check in recaptcha or not? For those who do not know: How to send a POST request to the url: with parameters: secret, response, remoteip? And the received server response from this request (it issues json there), decode and send by variables?

Google did not help, I ask for examples. Thanks in advance.


recaptcha accepts get requests

  $url = ''.(array_key_exists('g-recaptcha-response', $_POST) ? $_POST["g-recaptcha-response"] : '').'&remoteip='.$_SERVER['REMOTE_ADDR'];
$resp = json_decode(file_get_contents($url), true);

if ($resp['success'] == true) {
//все хорошо 
else {
// капча не решена

you need the captcha to be in the form itself, where you have all the inputs

Scroll to Top