I'm trying to get my Captcha to work. It works, but if the user does it correctly I want them to go to my thanks.html page, and I'm doing something wrong. Help?

  $privatekey = "Private Key numbers";
  $resp = recaptcha_check_answer ($privatekey,
  $to = 'myemail@myemail.com';
  $subject = 'Comment Form Title';
  $message = 'From: ' . $_REQUEST['name'] . "\n\n" . $_REQUEST['data'];
  $email = $_REQUEST['email'];
  $headers = 'From: ' . $email . "\r\n" .
            'Reply-To: ' . $email . "\r\n" .
          'X-Mailer: PHP/' . phpversion();

  if (!$resp->is_valid) {
    // What happens when the CAPTCHA was entered incorrectly
    die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
         "(reCAPTCHA said: " . $resp->error . ")");
  } else {
  mail ($to, $subject, $message, $headers);
header("Location: thanks.html");
    // Your code here to handle a successful verification


I can't see anything wrong, you should try using <?php ?> instead of <? ?> - it is not always enabled.

Does require_once('recaptchalib.php'); send anything to the browser, like text? Anything sent before the header() function will stop it from working. The large space at the beginning of the code may be the problem (when I said anything, I meant anything. Including spaces. ;))

Kieran :)

I collapsed a lot of the spaces and put the php at the start and it worked! I had the php their prior, so I think it was the spaces. Thank you Thank you, I would have never figured it out!

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.