Reputation: 33
I am trying to pass POST data to a function after performing a redirect. This is my code
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
}
}
how to pass to myfunction2
Upvotes: 0
Views: 527
Reputation: 1868
try this code, you have use session for this
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');
}
Upvotes: 1
Reputation: 4033
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
}
}
Upvotes: 0