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 }

    #2
    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

    Miva Web Developer
    Alchemy Web Development
    https://www.alchemywebdev.com
    Site Development - Maintenance - Consultation

    Miva Certified Developer
    Miva Professional Developer

    https://www.dev4web.net | Twitter

    Comment

    Working...
    X