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!";
  }
  ?>

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.

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?

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...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.