我的主控制器中有以下功能
public function Main_Search_Form()
{
$subs_id = $this->input->post('subs_id');
$town_id = $this->input->post('town_id');
$account_type = $this->input->post('account_type');
$postcode = $this->input->post('postcode');
$data = array("account_type" =>$account_type,
"subs_id" =>$subs_id,
"town_id" =>$town_id,
"postcode" =>$postcode
);
if($account_type == 'TUTOR')
{
redirect(base_url() . 'Tutor_Controller/Tutor_Search_Result',$data);
}
if($account_type == 'STUDENT')
{
redirect(base_url() . 'Student_Controller/Student_Search_Result',$data);
}
}
我首先检查$ account_type的值是TUTOR还是STUDENT。如果它是TUTOR,我想调用'Tutor_Controller'文件中的另一个函数。我的问题是如何通过Tutor_Search_Result函数中的数组'data'获取变量的值。
答案 0 :(得分:0)
您可以使用CodeIgniter的flashdata功能,该功能将数据发送到下一个请求:
https://www.codeigniter.com/user_guide/libraries/sessions.html#flashdata
<强>用法:强>
To send data:
$this->session->set_flashdata('acc_data', json_encode($data));
和
To read data:
$_SESSION['acc_data'];