根据字符串或数组的数据类型,有 3 种传递数据的方法(您可以使用下面解释的任何一种,根据您的要求):
通过视图
//For data you collected through POST method from FORM, collect them as array
$data=array(
'employee_name' => $this->input->post('emp_name'),
'employee_email' => $this->input->post('emp_email'),
'employee_password' => $this->input->post('emp_password')
);
$this->load-> view(''mynextpage", $data)
通过控制器
redirect('controller_name/index'.$valueofcustomer);
OR
redirect(base_url()."controller_name/index/".$valueofcustomer);
//then in your 'view', you can access value of customer like this:
$v_o_c = $this->uri->segment(3);
echo "your value is " .$v_o_c;
通过会话
$data = array(
'user_name' => $user_name,
'is_logged_in' => true
);
$this->session->set_userdata($data); //set the session
redirect('another_controller/index');
//then access those in another_controller like this:
$in = $this->session->set_userdata('$data');
Note: Session data will available only for redirect and lost on next page request