1

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?

<?
	  require_once('recaptchalib.php');
  $privatekey = "Private Key numbers";
  $resp = recaptcha_check_answer ($privatekey,
                                $_SERVER["REMOTE_ADDR"],
                                $_POST["recaptcha_challenge_field"],
                                $_POST["recaptcha_response_field"]);
  $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
  }
    ?>
2
Contributors
2
Replies
4
Views
6 Years
Discussion Span
Last Post by girlinthesun
0

Hi,

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 :)

Edited by Kieran Y5: n/a

0

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!

This question has already been answered. 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.