austin350s10 Posted May 28, 2009 Share Posted May 28, 2009 I am trying to use reCAPTCHA but I am running into some problems. The code below is my mail handler program. <?php require_once('recaptchalib.php'); $privatekey = "....."; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if(!$resp->is_valid) { header("location:captcha_error.html"); die(); } ?> <?php /*subject and email variables*/ $emailSubject = 'OptOut'; $webMaster = '[email protected]'; /*gathering data variables*/ $emailField = $_POST['email']; /*email field*/ $body = <<<EOD <br><hr><br> <h2>Please remove this email address from our mailing list</h2> <hr> $email <br> EOD; /*email sender script*/ $headers = "From: Website\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($webMaster, $emailSubject, $body, $headers); /*resultes*/ $theResults = <<<EOD <html> <body> Thank you </body> </html> EOD; echo "$theResults"; ?> The problem I am having is that when the user enters a wrong security code they are directed to a separate error page: captcha_error.html. The error page has a link on it that directs the user back to the form but when they go back to the form all the questions the user entered end up disappearing. Is there a way I can make the error message appear on the same page as the form itself? Or a way the form can hold its values? You can test the my web page http://www.affordablehomecare.org/functions/example-captcha.php Thanks, -Austin- Link to comment https://forums.phpfreaks.com/topic/160059-recaptcha-problems/ Share on other sites More sharing options...
Zhadus Posted May 28, 2009 Share Posted May 28, 2009 Submit the form to itself to do the checking, or change this redirect: if(!$resp->is_valid) { header("location:captcha_error.html"); die(); As far as saving the values if you navigate OFF of the page, you'll need to either store them in a database until they return and reload them, or if the information doesn't need to be secure, you can pass it back through the URL and use a $_GET request. Link to comment https://forums.phpfreaks.com/topic/160059-recaptcha-problems/#findComment-844396 Share on other sites More sharing options...
austin350s10 Posted May 29, 2009 Author Share Posted May 29, 2009 How do I pass the values back to the form using $_GET? I apologize but I am a total newbie to PHP and I really want to stop spammers on my website.... Thanks, -Austin- Link to comment https://forums.phpfreaks.com/topic/160059-recaptcha-problems/#findComment-844879 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.