验证码助手不起作用.控制器中的


captcha helper not working

验证码函数:

public function captcha(){
    $this->load->helper('captcha');
    $captcha = array(
        'word' => 'Random 123',
        'img_path' => './captcha/',
        'image_url' => base_url() . 'captcha/',
        'font_path' => './fonts/LucidaTypewriterBold.ttf',
        'img_width' => '300',
        'img_height' => '50',
        'expiration' => '3600',
    );
    $img = create_captcha($captcha);
    $dataf['image'] = $img['image'];
    $this->load->view('captcha_view', $dataf);
}

验证码查看文件:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Enter Captcha</title>
</head>
<body>
    <h3>Creating CAPTCHA</h3>
    <?php 
        echo $image;
        // echo '<br/>Word: ' .$word;
        // echo '<br/>time: ' .$time;
    ?>
</body>
</html>
这不会加载验证码

图像,只会加载标题"创建验证码"。此外,没有显示任何错误。

我是 php/codeigniter 的新手,请帮忙。

试试这个

加载验证码应该是这样的

$captcha_array = array(
    'name' => 'captcha',
    'class' => 'input_box',
    'color' => 'white',
    'placeholder' => '',
    'id' => 'captcha'
);
echo form_input($captcha_array);

您的控制器代码也应该更改。您也需要会话帮助

也请查看本教程