Help getting captcha working in PHP form with JS field validation

I have PHP form with JS field validation and I recently added the Google reCaptcha. I have everything working except when the Captcha fails I can’t get my error message to show. I’d be happy to share what I have and see if someone can guide me in the right direction.

Absolutely! Please feel free to post the source code and/or link to your form, and one of us who sees it would be happy to take a look :slight_smile:

I put this code in and I had the CaptchaFail parsing True

            main('Location: contactform.php?CaptchaPass=True');


	main('Location: contactform.php?CaptchaFail=True');

But I also added this snippet to get my error message and when I click send it seems to error out and the screen turns white.

    <?php if(isset($_GET['CaptchaFail'])){ ?>
    <div class="content_item">Captcha Failed, please try again</div>
    <?php } ?>

Latest update, I scrapped the previous method and went for something simple. I now have the following code in place and I get my Captcha error message but it seems to be always false and the message displays all the time. Now I need to figure out how to make false not show on screen until after send has been pressed.

       <?php if(isset($data->success)AND $data ->success == false) { 
   				echo "<h1>Captcha failed, please try again</h1>"; 

Actually this appears to be working now! Once I left the page and returned success was no longer false so the error message went away. Tested it without checking the reCaptcha and I got the error message, then tested checking the Captcha and the Message Sent worked as expected. @kirupa

1 Like