Welcome Guest, Not a member yet? Register   Sign In
Insert into database doesn't work with redirect
#1

[eluser]Unknown[/eluser]
Hi!

My controller code is the following :
Code:
function addtoDB()
    {
        $this->load->helper(array('form', 'date'));
        $this->load->library('form_validation');

        $this->form_validation->set_rules('day', 'day', 'required|numeric');
        
        if ($this->form_validation->run() == FALSE)
        {
            $this->load->view('header_view');
            $this->load->view('member_view');
            $this->load->view('footer_view');
        }
        else
        {
            $this->load->database();
            $data = array(
                ...
                        );

            if ($this->db->insert('rappels', $data))
            {
                $this->session->set_flashdata('message', 'okdb');
            }
            else
            {
                $this->session->set_flashdata('message', 'errdb');
            }
            sleep(2);
            redirect('member');
        }
    }

Inserting into the database doesn't work. But, if I comment redirect('member'), then the data is correctly inserted into the database...

Strange, isn't it?

I found a workaround by placing...
Code:
sleep(2);
just before the redirect, but I believe there must be a better solution.

I'm using ODBC and MS Access database.

I've had quite a few bugs in the past that I've been able to solve thanks to this forum, but I seem to be the first one experiencing this bug.

Any help is welcome, thanks in advance!


Messages In This Thread
Insert into database doesn't work with redirect - by El Forum - 03-13-2010, 04:07 AM



Theme © iAndrew 2016 - Forum software by © MyBB