Welcome Guest, Not a member yet? Register   Sign In
Redirecting to another controller passing the variable $data
#3

[eluser]eilrahc[/eluser]
I ran across this a couple weeks ago. Here's how I did it.

In the table, I show a delete link that looks like 'record/delete_confirm/$id'.

'delete_confirm' just presents a form to the user with Yes and No buttons. The form action is set to another controller method called 'delete', which looks like this:

Code:
public function delete() {
    if ($_POST['delete_confirm'] == "Yes") {
        $this->table_model->delete($this->uri->segment(3));
    }
    redirect('table');
}

The 'delete' method in the model does the work of actually removing the row. I should probably have some error checking in here (to check for a valid $this->id), but this is the gist of it anyway. The benefit to doing it this way is that you don't need an intermediate "hey, I'm doing what you asked" page, especially for something so small as deleting a row from the database.


Messages In This Thread
Redirecting to another controller passing the variable $data - by El Forum - 08-18-2008, 06:06 PM



Theme © iAndrew 2016 - Forum software by © MyBB