2

我似乎无法让 CI2 的验证码助手工作......有人能指出我做错了什么吗?

我想我已经按照文档上的所有步骤进行了操作,但是我没有收到任何事件 a print_r(get_defined_vars()) 没有显示任何内容... :(

我的控制器


function index()
{
$this->load->helper('form'); $this->load->helper('captcha'); $this->load->model('captcha');

   $vals = array(
    'word'   => 'Random word',
    'img_path'   => '../images/captcha/',
    'img_url'    => 'http://mysite/images/captcha/',
    'font' => '../../system/fonts/texb.ttf',
    'img_width'  => '150',
    'img_height' => 30,
    'expiration' => 7200,
    "time" => time()
   );

   $data['cap'] = create_captcha($vals);

   $cap = array(
    'captcha_time'  => $vals['time'],
    'ip_address'    => $this->input->ip_address(),
    'word'   => $vals['word']
   );

   $this->captcha_model->insert_captcha($cap);
   //print_r(get_defined_vars());   

   $data['main_content'] = 'admin/landing.php';
   $this->load->view('includes/template', $data);

}

我的模特

function input_captcha($data)
{
    $query = $this->db->insert_string('captcha', $data);
    $this->db->query($query);
}
我的观点

<section>
    <h3>You must captcha this captcha before proceeding to your demise!</h3>
    <article>
        <?php echo form_open('admin/auth');?>
            <p>Who the F are you?</p>
            <?php echo form_input('email', 'your real email!');?>
            <br>
            <?php    echo 'Submit the word you see below:';?>
            <br>
            <?php    echo $cap['image'];?>
            <br>
            <?php    echo '<input type="text" name="captcha" value="" />';   ?>
<br> <?php echo form_submit('submit', 'Send It!');?>
<?php echo form_close();?> </article> </section>

4

1 回答 1

1

问题出在图像的路径中。有一件事,即使将日志阈值设置为四,我也没有得到任何问题的迹象。我将其设置为绝对路径,一切正常...


    function index()
    {   
        $this->load->helper('form');
        $this->load->helper('captcha');
        $this->load->model('captcha_model');

        $vals = array(
            'img_path'   => '/var/www/mysite.com/images/captcha/',
            'img_url'    => 'http://mysite.com/images/captcha/',
            'font' => '../../system/fonts/texb.ttf',
            'img_width'  => '150',
            'img_height' => 30,
            'expiration' => 7200,
            "time" => time()
            );

        $data['cap'] = create_captcha($vals);

        $cap = array(
            'captcha_time'  => $data['cap']['time'],
            'ip_address'    => $this->input->ip_address(),
            'word'   => $data['cap']['word']
            );

        $this->captcha_model->add_captcha($cap);

        $data['main_content'] = 'admin/landing.php';
        $this->load->view('includes/template', $data);
    }
于 2011-03-04T21:38:21.467 回答