我正在尝试在执行重定向后将POST数据传递给函数。这是我的代码
class mycontroller extends CI_Controller {
function myfunction1(){
$data = array(
'code' => $this->mymodel->myautocode(),
'value1' => $this->input->post('value1'),
);
redirect(mycontrollers/myfunction2);
}
function myfunction2(){
// now, how to pass $data in here
$value2 = $value1
$code1 = $code
}
}
如何传递给myfunction2
答案 0 :(得分:1)
尝试此代码,您已使用此会话
function myfunction1(){
$data = array(
'code' => $this->mymodel->myautocode(),
'value1' => $this->input->post('value1')
);
$this->session->set_userdata($data);
redirect(mycontrollers/myfunction2);
}
function myfunction2(){
$value2 = $this->session->userdata('value1');
$code1 = $this->session->userdata('code');
}
答案 1 :(得分:0)
class mycontroller extends CI_Controller {
function myfunction1(){
$data = array(
'code' => $this->mymodel->myautocode(),
'value1' => $this->input->post('value1'),
);
return $data;
}
function myfunction2(){
$data = $this->myfunction1();
$value2 = $data['value1'];
$code1 = $data['code'];
//perform your operations here
}
}