How to pass variables coming from post, save them until the last step and show all values

1

I have a form that is divided into 10 parts, that is, I'm going to save via post the variables from page to page. However, if you refresh the page all previous variables are lost.

How can I solve the problem?

Outline:
Phase 1 - phase1_view - > Post - > phase1controller - > loadview_fase2
Phase 2 - phase2_view - > variable_phase1 (input hidden) - > post- > phase2controller- > loadview_fase3 (sends all saved variables to phase3)
Phase 3 - phase 3_view - > Variables_fase_1_e_2 (input hidden) - > post - > phase3controller - > loadview_fase_4 (sends all variables saved so far to the phase 4 view)
. . .

From then on ... But if you refresh the page, all variables are lost.

Thank you.

    
asked by anonymous 30.09.2015 / 11:17

2 answers

1

Use sessions, store each step in an array with the data, and place each step in a separate session with a primary key, for example:

$array = array(
    'etapa 1' => array(),
    'etapa 2' => array(),
    'etapa 3' => array()
);

$this->session->set_userdata($array);
    
01.10.2015 / 15:01
1

You can save the information using php in database or you can save in cookies

Let me show you an example:

link

What I would do would be, at each step I would save the information in cookies then at the end of the form when you have to save the information in the database or send by email I would get this information to cookies

link

setcookie($nome_para_a_variavel_cookie, $variavel_com_conteudo_aguardar_nesta_cookie, time() + (86400 * 30), "/");
    
30.09.2015 / 12:07