Announcement

Collapse
No announcement yet.

Adding form recaptcha

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Adding form recaptcha

    Trying to implement recaptcha on a contact for by request of the store owner. They are using the Luxe theme.
    I've got recaptcha working, but looking for how I can keep the form values in place if no recaptcha response is returned. Right now, the form resets itself.

    I've got the code on the page, and added the following to the contactForm.php. The form works, but when I return the msg if they haven't checked the captcha form, the form is blank. Any way to get the form to stay populated?

    I am stuck!

    Patty

    $captcha;
    if(isset($_POST['g-recaptcha-response']))
    {
    $captcha=$_POST['g-recaptcha-response'];
    }
    if(!$captcha)
    {
    echo 'Please check the captcha form.';
    exit;
    }

    /* Insert Your Secret Key Here - Not Your Site Key */
    $secret = 'mykey';
    $remoteip = $_SERVER['REMOTE_ADDR'];
    $response=file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$secret.'&response='.$captcha. '&remoteip='.$remoteip);
    if($response.success==true)
    { DO THE FORM STUFF }

  • I'm not too familiar with adding reCaptcha to a form, however I would think the reCaptcha check should check prior to actually submitting the form. The default form is submitted via AJAX, so the values shouldn't be removed unless the form processes correctly.
    Matt Zimmermann
    Director of UI/UX Standards and Theme Development
    / Miva, Inc.

    Comment

    Working...
    X

    This website uses cookies to identify visitors, track visitors to our website, store login session information and to remember your user preferences. By continuing to use this site you agree to our use of cookies. Learn More.

    This website uses cookies. By continuing to use this site you agree to our use of cookies. Learn More.

    Accept