0

I have an error message that is supposed to show if you forget to finish filling out the captcha form, but unfortunatly it shows on the very top of my site right when you enter the page... I don't want it to do that... I want the error messages to show after you fill the form out and submit.

Here is my php code that is responsible for the messages:

  <?php
  require_once('recaptchalib.php');
  $privatekey = "my_private_captcha_key";
  $resp = recaptcha_check_answer ($privatekey,
                                $_SERVER["REMOTE_ADDR"],
                                $_POST["recaptcha_challenge_field"],
                                $_POST["recaptcha_response_field"]);

  if (!$resp->is_valid) {
    echo "Sorry, your inquiry failed to submit. Please revise your inquiry and resubmit.";
  } else {
    echo"Thank you, your inquiry has been recieved! We will review it and get back to you as soon as possible!";
  }
  ?>
2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by Will Gresham
0

It will be showing all the time because you are checking if the captcha response only, you will need to also check if the form has been submitted otherwise the IF will always validate to true.

0

well, the problem is the fact that the message always appears... right when you enter the page, you see error message on top left of site... shall I send you the link so you can preview yourself?

0

you will need to also check if the form has been submitted otherwise the IF will always validate to true.

Of course it always shows, becuase until you submit the form $resp->is_valid will validate to FALSE...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.