CodeIgniter Forums
redirection problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: redirection problem (/showthread.php?tid=19805)



redirection problem - El Forum - 06-19-2009

[eluser]quest13[/eluser]
Can anyone tell me how to redirect to the function that has argument ?

I want to redirect after inserting in table like this,

function Addproperty($propertyid){
.....
....code here
}


function insert(){

$data=....To model-->function Addinsert
If($data)>0{

redirect('/Addproperty/'.$propid,'refresh');

}
}

Neither it is redirected nor it refreshes. I am getting header information error.

I tried this also


redirect('/Addproperty/'.$propid,''); , but no use.


Any suggestions ?


redirection problem - El Forum - 06-19-2009

[eluser]Thorpe Obazee[/eluser]
nvm me.


redirection problem - El Forum - 06-19-2009

[eluser]JE[/eluser]
its very simple, the syntax of redirect is redirect('controllername/property/param')

.... read the documentation.....


redirection problem - El Forum - 06-19-2009

[eluser]Zorancho[/eluser]
Make sure in your model function you return the last id after inserting.
Then in your controller:
Code:
function insert()
{
  $propid = $this->Model->do_the_insert();
  if($propid)
  {
     redirect('same_controller/addproperty/'.$propid, 'refresh');
  }
}
Always make sure you are getting the $propid after inserting, otherwise don't do the redirect.Do some testing to see what you are getting for it.
Code:
$propid = $this->Model->do_the_insert();
echo $propid;
exit;