1
我的主页是index.php
。我正在使用CAPTCHA,在提交表单后,它会检查CAPTCHA验证,如果该值是正确的,那么它会转到form.php
。如果该值不正确,则它将保持在同一页面上。我想使用AJAX功能验证CAPTCHA
我的问题是,如果CAPTCHA值不正确,它涉及到index.php和我已经在窗体中输入的所有值是null
。我需要我在表单中输入的值,即使CAPTCHA错误并要求输入新的CAPTCHA文本。
if(empty($_SESSION['6_letters_code']) || strcasecmp($_SESSION['6_letters_code'], $_POST['6_letters_code']) != 0)
{
$errors .= "\n The above code does not match!";
}
if(empty($errors))
{
header('Location:form.php');
}
function IsInjected($str)
{
$injections = array('(\n+)',
'(\r+)',
'(\t+)',
'(%0A+)',
'(%0D+)',
'(%08+)',
'(%09+)'
);
$inject = join('|', $injections);
$inject = "/$inject/i";
if(preg_match($inject,$str))
{
return true;
}
else
{
return false;
}
}
if(!empty($errors))
{
header('Location:index.php');
echo "The above code does not match!";
}