【问题标题】:codeigniter - captcha helper not workingcodeigniter - 验证码助手不起作用
【发布时间】:2016-01-31 16:03:34
【问题描述】:

控制器中的验证码功能:

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 的新手,请帮忙。

【问题讨论】:

  • 能否打印验证码数组??
  • 请检查您对验证码文件夹的权限。它应该是 666 或 777 。
  • 数组 ( [word] => 随机 123 [img_path] => ./captcha/ [image_url] => localhost/fapogee/captcha [font_path] => ./fonts/LucidaTypewriterBold.ttf [img_width] = > 300 [img_height] => 50 [过期] => 3600)
  • @Drudge 我更改了权限,但问题仍然存在!

标签: php codeigniter


【解决方案1】:

试试这个

加载验证码应该是这样的

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

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

Check this tutorial as well

【讨论】:

  • 谢谢!我实际上曾通过此链接尝试过:youtube.com/watch?v=RR3ODc0vDvA,它在视频中运行良好。
  • 使用我的。我确定链接。我只能给你推荐的是这个
  • 好的,我过段时间试试!
猜你喜欢
  • 1970-01-01
  • 2011-07-08
  • 1970-01-01
  • 2021-09-19
  • 2014-09-24
  • 1970-01-01
  • 1970-01-01
  • 2016-09-18
  • 2012-12-29
相关资源
最近更新 更多