|
PHP复制代码 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Login extends CI_Controller {
public function index (){
$this->load->view('admin/login.html');
}
/**
* 生成验证码
*/
public function code (){
$seed='abcdefghijk1234567890';
$word='';
for($j=0;$j<4;$j++){
$word.=$seed[mt_rand(0,strlen($seed)-1)];
}
$conf=array(
'img_width'=>'70',
'img_height'=>'30',
'word'=>$word
);
$this->load->helper('captcha');
$code=create_captcha ($conf);
$this->session->set_userdata('code',$code);
}
/**
* 登录
*/
public function login_in (){
$captcha=strtolower($this->input->post('verify'));
$code=$this->session->userdata('code');
echo $code;
die;
if($captcha==$code){
header("content-type:text/html;charset=utf8");
echo "验证码正确";
} else {
header("content-type:text/html;charset=utf8");
echo "验证码错误";
}
}
}
?> 复制代码
我确保了ci的session类的开启 并且key也已经设置!
发现打印出的code为空的 没有值!!!
求问怎么解决
求问大家 怎么解决
|
|