Help! Need reCaptcha to work

Discussion in 'PHP' started by buckmajor, Sep 9, 2010.

  1. #1
    Hi there,

    I have added reCapttcha to my form, signed up on Google for a API key,
    and so far nothing is working properly. My form is using javascripts
    for alert messages for text fields, and to validate. URL:
    http://www.dmaireroa.com/mail/contact.php. I have the following files:
    1. contact.php (form with reCaptcha)
    2. mailer.php (serverside - receive an email with the form output)
    3. confirm.php (confirmation page)
    4. folder 'javascripts' (7 files to make form work)
    5. recaptchaalib.php (Google reCaptcha)

    I have the following code in my form 'contact.php':
    ----------------------
    <form action="http://dmaireroa.com/mail/mailer.php?form=contact"
    id="contactForm" method="post">
    <fieldset>
    <?php
    require_once('recaptchalib.php');
    $publickey = "I put my public key here"; // you got this from
    the signup page
    echo recaptcha_get_html($publickey);
    ?>
    <input name="" class="button" type="submit" value="" />
    </fieldset>
    </form>
    ----------------------

    Where exactly do I put this code?
    ----------------------
    <?php
    require_once('recaptchalib.php');
    $privatekey = "your_private_key";
    $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
    }
    ?>
    ----------------------

    Thanks in advance
    CHEERS :)
     
    buckmajor, Sep 9, 2010 IP
  2. buckmajor

    buckmajor Active Member

    Messages:
    574
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #2
    I thought this one was too technical for some, oh well, will have to leave out the reCaptcha in my form then..

    Fanks, I still love you guys!
     
    buckmajor, Sep 9, 2010 IP
  3. buckmajor

    buckmajor Active Member

    Messages:
    574
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #3
    Fixed, all good now. I also added a ReCaptcha on my blog site too, yippy ;)
     
    buckmajor, Sep 23, 2010 IP