Really Simple Captcha Wordpress not validating


Really Simple Captcha Wordpress not validating

我的页面上有这段代码。

<?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>

当我试图输入错误的captcha图像时,它仍然发送表单,我显示了处理检查的变量,即使captcha图片是正确的,它也会不断返回"FALSE"值$correct变量总是返回false;

我通过替换(在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_eescape_string似乎不喜欢UTF-8字符编码,因此比较失败。