Welcome Guest, Not a member yet? Register   Sign In
Redirect on page edit after save
#1
Sad 

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");

            

        }

    }
Reply
#2

Huh nobody??
Reply
#3

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.
Simpler is always better
Reply
#4

$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

}
Reply




Theme © iAndrew 2016 - Forum software by © MyBB