我的页面上有这个代码。
<?php
$captcha_instance = new ReallySimpleCaptcha();
$captcha_instance->bg = array( 238, 238, 238 );
$word = $captcha_instance->generate_random_word();
$prefix = mt_rand();
$captcha_img = $captcha_instance->generate_image( $prefix, $word );
$captcha = plugins_url( '/really-simple-captcha/tmp/').$captcha_img;
$response = $_POST['response'];
$correct = $captcha_instance->check($prefix,$response);
var_dump($correct);
?>
<div id="main-container">
<?php if ( $pages->have_posts() ) while ( $pages->have_posts() ) : $pages->the_post(); ?>
<div class="page_overlay" style="display:none;"></div>
<div id="form-container">
<form method="post" action="<?php echo the_permalink();?>">
<input type="text" name="fname" id="fname" >
<img src="<?php echo $captcha; ?>" alt="captcha"/>
<input type="text" id="response" name="response" >
<input type="submit" name="submit" value="submit">
</form>
</div>
<?php endwhile; ?>
</div>
当我尝试输入错误的验证码图像时,它仍然发送表格,我显示了处理检查的变量,即使验证码图像正确,它也会继续返回“FALSE”值。 $ correct变量总是返回false;
答案 0 :(得分:0)
我通过替换(在 simple-contact-save.php 中)行来解决
if( $_SESSION['security_code'] == mysql_real_escape_string(trim($gcf_captcha)) && !empty($_SESSION['security_code'] ) )
与
if( $_SESSION['security_code'] == trim($gcf_captcha) && !empty($_SESSION['security_code'] ) )
似乎(不推荐使用)函数 mysql_real_escape_string 并不像UTF-8字符编码那样使比较失败。