Jump to content

Best Way To Save A Form In Sql Database?


rmpotter

Recommended Posts

You could quickly WHILE through the form inputs, sanitizing them and adding them to an associative array, then implode the array into a string to store in a database, so you've only made one db call, and then when you want the values again, read the one field with all the data and explode it into an array. You could have the value attribute of the input fields set to something like <?php echo ($_SESSION["fieldname"]?$_SESSION["fieldname"]:""); ?> and when you're reading the values again, set them to the session variable. But only good for temporary storage, as it compiles all your data into one field.

Link to comment
Share on other sites

It's probably better to use serialize and unserialize instead of implode and explode, serialize is specifically for creating a string representation of a structure like an array. You could serialize all of $_POST, for example, and store that in the session.

Link to comment
Share on other sites

It's probably better to use serialize and unserialize instead of implode and explode, serialize is specifically for creating a string representation of a structure like an array. You could serialize all of $_POST, for example, and store that in the session.
This is what I have done in the past and it works awseome for simple forms. This form is very complex and reloading all the values would be time consuming to program and prone to error... Is it possible to take a PHP array and load it into a java array? I would hope that by doing so I could run through each variable by name and repopulate it once the form has loaded again.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...