Passing multiple parameters in a redirect function

I want to pass multiple parameters to a function in the same controller. Here is my redirect function when I run this code and then show the warning.

Message: Missing argument 2 for greeting :: sendVerificatinEmail ()

redirect('welcome/sendVerificatinEmail/'.$name,$email ,$request_tracking_no);

+3


source to share


2 answers


Try:

redirect('welcome/sendVerificatinEmail/'.$name.'/'.$email.'/'.$request_tracking_no);

      



Your method:

function sendVerificatinEmail($name, $email, $request_tracking_no){
    //...
}

      

+2


source


In Codigniter, all post data will be destroyed during the redirect and you will have to use session variables to send the data. try this: I hope to help

$data = array('param1'=>'ali','param2'=>55);
// store data to flashdata
$this->session->set_flashdata('data',$data);
// redirect  to your controller
redirect('controller/method')  
//in other side
$array = $this->session->flashdata('data');

      



actually Codeigniter uses $ _SESSION and you can use sessions directly instead of flash data like this:

//first
$_SESSION['flash'] = implode('@',array(a,b,c));
//then
$flash = $_SESSION['flash'];
$array = explode('@',$flash);
unset($_SESSION['flash']); //free it

      

+1


source







All Articles