Google reCAPTCHA

3 posts by 1 authors in: Forums > CMS Builder
Last Post: January 7, 2019   (RSS)

By gversion - January 7, 2019

Hello,

My website is being attacked by bots and I urgently need to set up a Google reCAPTCHA on the user registration form.

I have followed the instructions from this archived post: https://www.interactivetools.com/forum/forum-posts.php?postNum=2236652

This all looks fine except that users can submit the form without needing to click the "I am not a robot" checkbox.

So it seems that the following code is not being triggered:

if (!$recaptchaResponse['success']) {
        if (is_array($recaptchaResponse['error-codes'])) { 
          if (in_array('missing-input-secret', $recaptchaResponse['error-codes']))     { $errorsAndAlerts .= "There's a problem with recaptcha, please let us know! (no secret)<br/>\n"; }
          if (in_array('invalid-input-secret', $recaptchaResponse['error-codes']))     { $errorsAndAlerts .= "There's a problem with recaptcha, please let us know! (invald secret)<br/>\n"; }
          if (in_array('missing-input-response', $recaptchaResponse['error-codes']))   { $errorsAndAlerts .= "Please fill out the recaptcha box!<br/>\n";
         $showSignupForm = true; // do we need this line?
           }
          if (in_array('invalid-input-response', $recaptchaResponse['error-codes']))   { $errorsAndAlerts .= "Please fill out the recaptcha box again, your answer was incorrect!<br/>\n"; $showSignupForm = true; // do we need this line?
          }
        }
        if (!$errorsAndAlerts) { $errorsAndAlerts .= "Invalid captcha response, please try again or contact us directly and let us know."; }
        @trigger_error("Failed recaptcha on signup form", E_USER_NOTICE);
      }

Can someone please assist?

Thank you,

Greg

By gversion - January 7, 2019

For anyone else that may want two levels of form validation (PHP and jQuery Validation), this article provided the answer: https://bubinga.co/combining-googles-recaptcha-and-jquery-validate/