I'm sure there is a solution for that, I've already try to google what I'm looking for but no anser yet, So here is my little problem, I have a form with captcha, the captcha put it's orignal string in $_SESSION['PASSWORD']
, so I'd like to verify that user tape the same string as in the $_SESSION['PASSWORD']
.
Well I think I need a little ajax here, before I submit the form I have to check The $_SESSION['PASSWORD']
with the ajax and compare it with what user tape
Any help please, 'I'm not pro in ajax ' it would be great that you make it very simple form me.
HTML
<input type="text" id="captcha" name="captcha"> <!-- This is your captcha input -->
JQuery:
$.get('verify.php', { captcha: $('#captcha').val() }, function(data){
if(data === 'OK'); //Validation is ok
else; //Validation is wrong
});
PHP (verify.php):
<?php
session_start();
if($_GET['captcha'] === $_SESSION['password']) echo 'OK';
else echo 'ERROR';
exit();
?>