Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Web Design (WordPress, Joomla, etc.) Captcha Issue – Validates and Sends Email but Does Not Redirect

  • Captcha Issue – Validates and Sends Email but Does Not Redirect

    Posted by Maria Marmol on June 16, 2011 at 7:52 pm

    I had a php form that sends an email and redirects to a “thank you” page all working fine.

    After adding the Google captcha code, and lots of troubleshooting, the captcha works and validates, the form sends the email as intended, but it does NOT redirect to the thank you page as it’s supposed to, and as it used to.

    Any help is appreciated. Thanks!!

    Here’s the “function” php code: (I’ve hidden some fields for obvious reasons)

    <?php
    require_once(‘recaptchalib.php’);
    $privatekey = “—Hidden—“;
    $resp = recaptcha_check_answer ($privatekey,
    $_SERVER[“REMOTE_ADDR”],
    $_POST[“recaptcha_challenge_field”],
    $_POST[“recaptcha_response_field”]);

    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 {
    // Your code here to handle a successful verification
    }

    // Configuration Settings
    $SendFrom = “—Hidden—“;
    $SendTo = “—Hidden—“;
    $SubjectLine = “Form Results – Testing Captcha”;
    $ThanksURL = “maint_thankyou.php”; //confirmation page
    $Divider = “~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~”;

    // Build Message Body from Web Form Input
    $MsgBody = “n$Dividern”;
    foreach ($_POST as $Field=>$Value)
    $MsgBody .= “$Field: $Valuen”;
    $MsgBody .= “n$Dividern”; //make content safe

    if (preg_match( “/bcc:|cc:|multipart|[url|Content-Type:/i”, implode($_POST))) {
    $spam=true;
    }

    // Send E-Mail and Direct Browser to Confirmation Page
    mail($SendTo, $SubjectLine, $MsgBody, “From: $SendFrom”);
    header(“Location: $ThanksURL”);
    ?>

    Maria Marmol replied 15 years, 2 months ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy