siabenie 0 Junior Poster in Training

Hi all,

I would like to ask if anyone could help me about AJAX validation error message with CAPTCHA (secureimage) - At the moment the error message display at processForm.php, IF user entered a wrong code.

But what I would like do to is; the error message will POP UP on the same page on checkForm.php instead of the next page. I managed to show the error message if user did not fill the code field but not able to show the error message IF user entered the code incorrect.

Basically I have forms (checkForm.php, processForm.php & thankyou.php) - I have all the standard check error / validation which is in JavaScript e.g.


<script type="text/javascript">


  $('#btn_submit').click(function() {
    var error_num = 0;
    var error_mesg = "";
      error_mesg += "Please enter your name\n";
      error_mesg += "Please enter the image verification\n";
    }else if(error_num==0){
    return false;


<!--And the rest are just HTML code-->
    <td width="20%">Name</td>
    <td width="80%"><input name="name" type="text" id="name" size="30" /></td>
<table width="100%" border="0" cellspacing="5" cellpadding="0">
    <td width="20%"><input type="text" name="captcha_code" size="20" maxlength="6" />
<a href="#" onclick="document.getElementById('captcha').src = '/securimage/securimage_show.php?' + Math.random(); return false">
[ Different Image ]</a></td>
    <td width="80%"><img id="captcha" src="/securimage/securimage_show.php" alt="CAPTCHA Image" /></td>



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 />";
  echo "The code you entered was incorrect. Please go <a href='javascript:history.go(-1)'>back</a> and try again. ";

<!--The rest of the code are just connection to DB-->

Can anyone assist me on this please? Thanks in advance.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.