Adding Captcha to a Ajax Contact form

Discussion in 'PHP' started by swapshop, Dec 1, 2008.

  1. #1
    Need hand in the right direction

    Using a ajax contact form but it doesnt have caphta

    Trying to add this captcha code
    http://www.phpcaptcha.org/documentation/quickstart/

    to this Ajax contact form
    http://www.dustindiaz.com/ajax-contact-form/

    added
    <img id="captcha" src="/securimage/securimage_show.php" alt="CAPTCHA Image" />
    <input type="text" name="captcha_code" size="10" maxlength="6" />
    <a href="#" onclick="document.getElementById('captcha').src = '/securimage/securimage_show.php?' + Math.random(); return false">Reload Image</a>

    the image appears and I can refresh it ok

    the form using contact.php to process the form so I added

    <?php session_start(); ?>

    include_once $_SERVER['DOCUMENT_ROOT'] . '/securimage/securimage.php';

    $securimage = new Securimage();

    if ($securimage->check($_POST['captcha_code']) == false) {
    // the code was incorrect
    // handle the error accordingly with your other error checking

    // or you can do something really basic like this
    die('The code you entered was incorrect. Go back and try again.');
    }


    Issue is its not even looking at the captcha code. I checked the source of the contact form and I can see a session var either?

    Pulling my hair out could some one please assist me?
     
    swapshop, Dec 1, 2008 IP
  2. VishalVasani

    VishalVasani Peon

    Messages:
    560
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hello,

    I am not getting your problem. Can you provide more details.?

    If you are looking for session variable for captcha then it is
    $_SESSION['securimage_code_value']
    Code (markup):
     
    VishalVasani, Dec 1, 2008 IP
  3. swapshop

    swapshop Peon

    Messages:
    656
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    0
    #3
    sorry what I mean is when I try to implement the captahc into the ajax contact form I don't see a session variable in the source as per the demo.

    not sure if this is the actual issue. I need some one to tell me where the error checking is to put the last two lines of code.

    Each time I try to add the code it seems to ignore the include and carry on posting the message

    I am getting slammed spam wise.
     
    swapshop, Dec 1, 2008 IP