views:

22

answers:

1

I have a link that calls this function:

function delete($id)
{   
    //Delete from database
    $this->db->delete('messages', array('id' => $id)); 

    $data['delete_message'] = 'Message was successfully deleted';
    redirect('admin');
}

As you can see I redirect to the admin function, and I want to pass the delete_message to that function. How can I do this?

+4  A: 

Have you looked at "Flashdata"?. You can set your success message in the flash and the next page (admin in your case) reads it if available and passes it to the view as a regular $data['foo'].

DrColossos
I agree with DrColossos...flashdata would do the job perfectly.
treeface
sorry guys but this seems like a pretty basic question and that doesn't really fit the bill for me.
mdgrech
why doesn't it fit the bill? thats the standard way of handling such a situation. a message is placed in the session and displayed on the next page view.
Stephen Curran
I agree with Stephen. This is the most basic way of doing it. You only need to change one line in your code above and add anothter one to the view, can't get any simpler.
DrColossos