我试图在成功登录后重定向到另一个控制器home.php,但不知何故,url指向正确的控制器,但我得到一个空白页,即使我尝试回应“某事”;死;在home.php的index()中,它不显示回显的消息。
我的控制器代码是:
的login.php
function index(){
//if Admin already logged in, send to Admin home
$this->data['message']='';
$this->data['msg_class'] = '';
$post_array=$this->input->post();
$data['old_images']=$this->mod_common->getBgImages();
if($this->input->cookie('remember') == 'on')
{
//echo $this->input->cookie('username');
$this->data['message']=strip_tags($this->mod_login->check_cookie_login());
if($this->data['message']=='Login Successful'){
$this->data['msg_class'] = 'sukses';
redirect('home');
}else{
$this->data['msg_class'] = 'gagal';
}
}
if($this->input->post('action')=='adminLogin'){
//print_r($this->input->post()); die;
if(isset($post_array['remember'])){
$username_cookie= array(
'name' => 'uusername',
'value' => $post_array['username'],
'expire' => '865000',
'secure' => FALSE
);
$password_cookie= array(
'name' => 'userpass',
'value' => $post_array['userpass'],
'expire' => '865000',
'secure' => FALSE
);
$remember_cookie= array(
'name' => 'remember',
'value' => 'on',
'expire' => '865000',
'secure' => FALSE
);
$this->input->set_cookie($username_cookie);
$this->input->set_cookie($password_cookie);
$this->input->set_cookie($remember_cookie);
//die;
}
else
{
if($this->input->cookie('remember') == 'on')
{
if($this->input->cookie('uusername') != $post_array['username'])
{
delete_cookie("remember");
delete_cookie("uusername");
delete_cookie("userpass");
}
}
}
$this->data['message']=strip_tags($this->mod_login->validate_admin_login());
if($this->data['message']=='Login Successful'){
$this->data['msg_class'] = 'sukses';
/* this is where it is taking the home page from */
redirect('home');
}else{
$this->data['msg_class'] = 'gagal';
}
} /*else if(isset()){
}*/
///////////////////////
$this->data['cookieRemember'] = $this->input->cookie('remember');
$this->data['cookieUsername'] = $this->input->cookie('username');
$this->data['cookiePassword'] = $this->input->cookie('userpass');
//echo $this->data['cookieRemember'];echo $this->data['cookieUsername']; echo $this->data['cookiePassword'];
//////////////////////
$this->data['cookiename'] = $this->input->cookie('name', false);
$this->data['cookieimage'] = $this->input->cookie('image', false);
$sess_msg = $this->session->userdata('session_msg');
$session_msg_class = $this->session->userdata('session_msg_class');
if(isset($sess_msg) && $sess_msg!= ''){
$this->data['message']=$sess_msg;
$this->data['msg_class'] = $session_msg_class!=''?$session_msg_class:'gagal';
}
//render full layout, specific to this function
$this->load->view('login', $this->data);
}
home.php(重定向控制器)
function index(){
global $USER;
$data = array();
//if Admin already logged in, send to Admin home
#$this->data['maincontent'] = $this->load->view('maincontents/gridview',$data,TRUE);
$data['lastlogin_details'] = $this->admin_lastlogin_details();
$data['thought_day'] = $this->mod_common->getPageDesc('thoughtOfTheDay');
if($this->input->post()) {
$post_array = $this->input->post();
$data['comments_msg'] = $this->mod_common->save_comments($post_array);
$data['announcement_id']= $post_array['announcement_id'];
}else{
$data['announcement_id']= $data['announcements'][0]['id'];
}
$data['announcements'] = $this->mod_common->get_announcements(4);
$announcements_likes = $this->mod_common->get_announcements_likes();
foreach($announcements_likes as $al)
{
$data['announcements_likes'][]= $al->announcement_id;
}
$comments_likes = $this->mod_common->get_comments_likes();
foreach($comments_likes as $al)
{
$data['comments_likes'][]= $al->comment_id;
}
if($data['announcements'][0]['id']!= '')
$data['announcement_comments']=$this->mod_common->get_comments_by_id($data['announcements'][0]['id']);
$data['workspace'] = $this->mod_common->get_workspace();
$data['gallery'] = $this->mod_common->get_array_frontend_raw('pr_gallery');
$data['count_bday_serComp'] = $this->mod_common->count_bDay_serComp();
$data['count_newjoinees'] = $this->mod_common->count_new_joinees();
//$data['category_name'] =$this->mod_common->get_category_by_id(1);
$data['birthdays'] = $this->mod_common->get_birthdayList();
$data['service_completion']=$this->mod_common->get_serviceCompletion();
$data['new_joinees']=$this->mod_common->get_newJoineesList();
$data['quick_links'] = $this->mod_common->get_cat_array2('pr_quicklinks','','','title');
$this->data['maincontent'] = $this->load->view('maincontents/dashboard',$data,true);
$this->load->view('layout', $this->data);
}