Store form data temporarily before writing to the database

Asked

Viewed 776 times

3

How do I store data from a form temporarily before entering it into the database? I have a form with a set of fields. After the user fills the set of fields, he will have the option to add another set with the same fields to insert new values. I would like to enter it into the database only when the user has completed the completion. Each set of fields should be a record in the table. How can I do that?

  • 2

    You can use the $_SESSION to store these elements.

  • Will work for inputs with the same name?

  • 1

    Or you can always create a temporary table.

  • you want to save to the user or to the server?

  • I want to save the data to the user

Show 1 more comment

1 answer

1


You can create an array in $_SESSION and for each set you add a new index in the array. To do this search for the size of the array and:

$_SESSION[$tamanho+1]['nome'] = $_POST['nome'];

Browser other questions tagged

You are not signed in. Login or sign up in order to post.