我有这个工作,然后突然改变了一些东西,我的php验证码不断失败。我觉得这可能是服务器方面的问题,但我找不到任何错误。
我正在使用
我正在网站的根级别对此进行测试。
<?php
session_start();
require_once('securimage/securimage.php');
?>
<form class="" method="post" action="" enctype="multipart/form-data" id="captcha">
<?php
$options = array();
$options['namespace'] = 'captcha';
$options['input_id'] = 'captcha_code';
echo Securimage::getCaptchaHtml($options, Securimage::HTML_IMG);
echo Securimage::getCaptchaHtml($options, Securimage::HTML_ICON_REFRESH);
echo Securimage::getCaptchaHTML($options, Securimage::HTML_INPUT);
?>
<input type="submit" value="submit">
</form>
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
$captcha_code = isset($_POST['captcha_code']) ? $_POST['captcha_code'] : null;
$image = new Securimage();
var_dump($_SESSION);
if($image->check($captcha_code) == true)
{
echo "Captcha was good!";
}
else
{
echo "Captcha did NOT match!";
}
}
?>
验证码$ SESSSION []已正确设置。
array(4)
{
["securimage_code_disp"]=> array(1)
{
["captcha"]=> string(6) "LG2BE2"
}
["securimage_code_value"]=> array(1)
{
["captcha"]=> string(6) "lg2be2"
}
["securimage_code_ctime"]=> array(1)
{
["captcha"]=> int(1457447465)
}
["securimage_code_audio"]=> array(1)
{
["captcha"]=> NULL
}
}
但无论我尝试什么,if条件总是失败。返回False。
if($image->check($captcha_code) == true)
{
echo "Captcha was good!";
}
else
{
echo "Captcha did NOT match!";
}
除验证部分外,一切正常。它拒绝工作。