Jump to content

Secure image


siabanie

Recommended Posts

Hi all,

 

I wonder if anyone could help me out; I have a PHP form that need to put a secure image to prevent spam.

 

I have use this code provided in this page http://www.phpcaptcha.org/ - It works fine but the problem was when user entered an incorrect code it form still proceed which it not right.

 

My form involved some PHP and Javascript to handle the error messages - I wonder if I need AJAX script for this as well?

 

I use this Javascript to validate if the form has been enter blank or not:

 

..
..
$('[name=captcha_code]').parent().removeClass('error');
    if($('[name=captcha_code]').val()==""){
      error_num++;
      error_mesg += "Please enter the image verification\n";
      $('[name=captcha_code]').parent().addClass('error');
    }
..
..

 

And I need to put this code for matching code to verify if the code incorrect or correct. If incorrect a error message will display together.

if ($securimage->check($_POST['captcha_code']) == false) {
  // the code was incorrect
  // you should handle the error so that the form processor doesn't continue

  // or you can use the following code if there is no validation or you do not know how
   echo "The security code entered was incorrect.<br /><br />";
  //echo "Please go <a href='javascript:history.go(-1)'>back</a> and try again.";
  //exit;
}

 

Can someone please assist me about this.

 

Thanks in advance.

 

Link to comment
Share on other sites

Hello, does anyone can help me how I can validate CAPTCHA using AJAX? I have a form that check all the field error msges using jQuery but I don't know how I can do this using AJAX.

<?php
session_start();
require("include/application_top.php");
include_once $_SERVER['DOCUMENT_ROOT'] . '/securimage/securimage.php';

$securimage = new Securimage();
if ($securimage->check($_POST['captcha_code']) == false) {
   echo "The security code entered was incorrect.<br /><br />";
//exit;
//}
?>

 

This snippets will displayed if field is empty

$('[name=captcha_code]').parent().removeClass('error');
    if($('[name=captcha_code]').val()==""){
      error_num++;
      error_mesg += "Please enter the image verification\n";
      $('[name=captcha_code]').parent().addClass('error');
    }

 

This snippets (not working) will displayed if code entered is not match the code...but I think I need to add AJAX script somewhere which I need help.

$('[name=captcha_code]').parent().removeClass('error');
   if ($securimage->check($_POST['captcha_code']) == false){
      error_num++;
      error_mesg += " The security code entered was incorrect \n";
      $('[name=captcha_code]').parent().addClass('error');
    }

 

Anyone?

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.