PHP: How to save data for multi-page forms?

Status
Not open for further replies.

Mr. tech

In Runtime
Messages
384
What is the best way to save data from a multi-page form? Can I create a session and an array? E.g:

PHP:
$_SESSION['form_data'] = array();

$_SESSION['form_data']['page_1'] = array();
$_SESSION['form_data']['page_2'] = array();

$_SESSION['form_data']['page_1']['field_1'] = $_POST['field_1'];
$_SESSION['form_data']['page_1']['field_2'] = $_POST['field_2'];
$_SESSION['form_data']['page_1']['field_3'] = $_POST['field_2'];

$_SESSION['form_data']['page_2']['field_1'] = $_POST['field_1'];
$_SESSION['form_data']['page_1']['field_2'] = $_POST['field_2'];

Or is it better to store it in a MySQL Database? Or what other way would you recommend?
 
If it is sensitive data then a database is much more secure.

Otherwise, that way should work fine.
 
Status
Not open for further replies.
Back
Top Bottom