求助:关于ci验证码局部刷新的问题?
1、生成验证码的方法写在了model里//注册验证码
function captcha()
{
$this->load->helper(array('captcha','url'));
$vals = array(
'word' => '',
'img_path' => './resources/images/captcha/',
'img_url' => base_url().'/resources/images/captcha/',
'font_path' => './resources/font/activai.ttf',
'img_width' => '137',
'img_height' => 39,
'expiration' => 5 *60 //5分钟过期
);
$cap = create_captcha($vals);
return $cap;
}
2、在控制器中调用model->方法
//获取user_model中的验证码
$captcha=$this->user_model->captcha();
//$data['captcha_img']= $captcha['image'];
//$_SESSION['captcha_word']=$captcha['word'];
$data['captcha_image'] =$captcha['image'];//传图片变量到视图
$captcha_word =$captcha['word'];
$this->session->set_userdata('captcha_word', $captcha_word);//验证码文字写入session
3、在视图输出验证码图片
<?php echo $captcha_image;?>
问题:1、怎么实现局部刷新? 2、如果把调用model方法单独写在控制器类下的一个方法里,怎么把验证码图片输出到视图中?
本帖最后由 Closer 于 2015-1-8 23:38 编辑
參考 CI 社區 - CI 驗證碼 Captcha (含點圖刷新)
上面網址裏面的 view 有部分程式碼被吃掉了
<a href="#" title="換一張" id="captcha" >
我明天上班再編輯一次
已修正完畢
可以去看看了
Closer 发表于 2015-1-9 09:32
已修正完畢
可以去看看了
感谢
Parse error: syntax error, unexpected ' function' (T_STRING), expecting function (T_FUNCTION) in E
出现这个是什么意思
页:
[1]