CodeIgniter Forums
Redirect on page edit after save - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Redirect on page edit after save (/showthread.php?tid=64404)



Redirect on page edit after save - webgirl - 02-16-2016

Hi guys am new to the forum

I need to create a form that saves the partial data of a form and continues in another step with the same pageId

example: load form->save->after save redirect to editpage/pageId

this is the first step code,

how do I go to the second step to complete the application form with the same pageid?
are slightly desperate  Huh   ... can someone please help me? thank you

Code:
function step1()

    {



        if (!$this->ion_auth->logged_in())

        {

            //redirect them to the login page

            redirect('auth/login', 'refresh');

        }

        elseif (!$this->ion_auth->is_admin()) //remove this elseif if you want to enable this for non-admins

        {

            //redirect them to the home page because they must be an administrator to view this

            return show_error('You must be an administrator to view this page.');

        }

        else

        {

                   $data = array(
                       
         
                   'surname'=> $this->input->post('surname'),
                   'name'=> $this->input->post('name'),

       
                   );
                   
                   $this->db->insert('data_form',$data);
                   redirect("backend/Controller/function");

            

        }

    }



RE: Redirect on page edit after save - webgirl - 02-17-2016

Huh nobody??


RE: Redirect on page edit after save - donpwinston - 02-17-2016

I think you're asking how to pass the page_id to the next form. 

redirect("x\y\$page_id")

x is the controller class. y is a function in x. And page_id is the parameter of function y.


RE: Redirect on page edit after save - keulu - 02-17-2016

$this->db->insert('data_form',$data); return you the last_insert_id()


so you can write

$data_form_id = $this->db->insert('data_form',$data);
redirect("backend/page/edit/".$data_form_id);



[...] method edit in page controller

public function edit($data_form_id = null){
if (is_null($data_form_id)){
show_404(); // security
}

// do you stuff with $data_form_id

}