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

[eluser]Unknown[/eluser]
Hi,

I´m working on a piece of a CMS based on CodeIgniter, and this piece of code is for creating and managing slideshows.
The problem I´m encountering is in the beginning of the Controller function, I want to check if the slideshow exists in the database. If it exists, continue with the rest of the code. If it doesn´t exist, set up an error message, with flashdata. And redirect to the homepage (where the error message is displayed).

My code is like this:

Code:
public function slideshow($showid){
$query = $this->db->where('id',$showid)->get('slideshows');
if($query->num_rows() < 1){
  $this->session->set_flashdata('error','Slideshow doesn\'t exist.');
  redirect('admin/index','refresh');
}

$data['page'] = 'slideshow';
$data['title'] = 'Slideshows';
$this->scripts->load_scripts(array());
$this->scripts->load_functions(array());
$this->load->view('admin/dashboard_template.php',$data);
}

Well, onto the problem. What actually happens is this. When the slideshow doesn't exist, I get the error message set, and the redirect happens. Everything fine.
But when the slideshow does exist, I don't get the redirect, as expected. But I do get the flashdata set... so even though it shouldn't get into the if-loop, it does set the flashdata. I've even put some other things in the if-loop, like die(), echo 'hello'; etc. But only the set_flashdata() runs, no other code..

Can someone help me, cause I can't seem to find the solution to this.

Thank you!




Theme © iAndrew 2016 - Forum software by © MyBB