January 15, 201016 yr Hello all, I have setup recaptcha on my form and am having a few problems. My form layout is as follows - Form.php - page containing form fields and reCaptcha - source code is below - <?php require_once('recaptchalib.php'); $publickey = "XXXXXXXXXXXXXXXXXXXXXXXXX"; // you got this from the signup page echo recaptcha_get_html($publickey); # the response from reCAPTCHA $resp = null; # the error code from reCAPTCHA, if any $error = null; # are we submitting the page? if ($_POST["submit"]) { $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if ($resp->is_valid) { echo "You got it!"; # in a real application, you should send an email, create an account, etc } else { # set the error code so that we can display it. You could also use # die ("reCAPTCHA failed"), but using the error message is # more user friendly $error = $resp->error; } } echo recaptcha_get_html($publickey, $error); ?> ---------------------------------------------------------------------------------------------------- Process.php - page containing mail intructions as well as redirect if recaptcha was a success. <?php require_once('recaptchalib.php'); $privatekey = "XXXXXXXXXXXXXXXXXXX"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if(!$resp->is_valid) { header("location:newsletter-success.php"); die(); } else if($resp->is_valid) { header("location:newsletter-error.php"); } mail( "XXXXXXXXXXXXXX", "Newsletter Sign Up", "\nEnquiry From: - $name \nPostcode: - $postcode \nTelephone Number: - $telno \nEMAIL ADDRESS:- $email \nFurther Detail:- $furtherdetails \nPrefered Contact Time:- $contacttime \nInterested in the following newsletter/s:- $newsletters", "From: NewsLetterService@XXXXXXXXXXXXXX" ); ?> ------------------------------------------------------------------------------------------ Success.php - reCapthcha and information sent ok! Error.php - reCaptcha error page with back function to re-enter reCaptcha code. The form sends, and directs to the process.php form page, just stays there, it doesn't then re-direct to the success or error page? Please help, Regards
Create an account or sign in to comment