Php 验证码在我的自定义插件中不起作用

Php 验证码在我的自定义插件中不起作用,php,session,wordpress,captcha,Php,Session,Wordpress,Captcha,我正在尝试创建一个带有验证码的联系人表单,但验证码不起作用。 我在另一个文件中创建了验证码图像,并在会话中存储了值: //I already have start session and the beginning of file header('Content-Type: image/jpeg');// defining the image type to be shown in browser widow imagejpeg($image);//showing the image image

我正在尝试创建一个带有验证码的联系人表单,但验证码不起作用。 我在另一个文件中创建了验证码图像,并在会话中存储了值:

//I already have start session and the beginning of file
header('Content-Type: image/jpeg');// defining the image type to be shown in browser widow
imagejpeg($image);//showing the image
imagedestroy($image);//destroying the image instance
$_SESSION['image_code'] = $code;
在形式方面,我通过以下方式进行比较:

if(empty($_SESSION['image_code'] ) ||
      strcasecmp($_SESSION['image_code'], $_POST['posted_captcha']) != 0)
    {
    //Note: the captcha code is compared case insensitively.
    //to overcome this i can use
    // strcmp()
        $errors .= "\n The captcha code does not match!";
    }
这是我的CAPTCHA图像:

我的表单在不比较验证码的情况下继续发送电子邮件

可能是我的插件没有获取图像的会话值。我试图在wp-config.php、wp-load.php和plugins文件中添加sessionstart,但验证码保持不变。
感谢您的帮助:)

您是否已开始会话。。。会话_start();试着放一些像
echo“Hello”这样的词
插入该if语句,查看它是否到达了该代码的该部分。