Welcome Guest, Not a member yet? Register   Sign In
redirection problem
#1

[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 ?
#2

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

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

.... read the documentation.....
#4

[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;




Theme © iAndrew 2016 - Forum software by © MyBB