Securimage CAPTCHA Form Processing
I am currently implementing securimage on my website for captcha. The example that is given in the quickstart guide works perfectly fine. But instead of directing to process page and echo a random statement, i would like it to behave in the same way as in the demo page which displays a message box when wrong captcha is entered on the same page. I looked around the source code for javascript or Jquery that enables this functionality but unable to find anything. Any pointers appreciated to achieve this functionality.
Flow i want to achieve is;
->form entered -> goes to "process.php" ->if "wrong value for captcha" - "echo in main form". How can i display the echo statement on the form itself? that is what i want to find out. Not directing user to "process.php" file and display the error echo.
Here is the partial process code that determines whether value entered to captcha is right or wrong.
include_once $_SERVER['DOCUMENT_ROOT'] . '/securimage/securimage.php';
$securimage = new Securimage();
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 follow开发者_JAVA技巧ing code if there is no validation or you do not know how
$captchaerror = "The security code entered was incorrect.<br /><br />";
exit;
}
You can check the CAPTCHA on the server side and then return a POST/GET parameter which indicates a PHP script that the user has entered a wrong CAPTCHA. For example:
<?php
if ($_GET['error']="cap")
echo "captch error";
else
{}//dont echo
?>
I don't know about this securimage but this should be possible.
The test can't be done client side in javascript, because the client isn't allowed to know the answer. If it did it would be trivial for a bot to circumvent the captcha.
Like @dagon said, the demo isn't performing the check in the page, but reloading the same page with the error mesage box html inserted.
精彩评论