Reputation: 19
I have a long PHP/HTML form, which users will fill in. I need a way to be able to save the form, so that the user can access the partially filled form and continue filling it at a later time. The form is linked to a MySQL database. When the page is first opened the blank form is displayed. Once the user presses 'Submit', the user data goes into the database. How can I save a partially filled out form, so that a user can exit the application, log out, and log in later to continue filling out the form?
Further clarification: I am thinking that a possible solution may be to create a record in the database when the user clicks 'Save'. My question is mainly how to retrieve the saved form. Do I need to fill in the 'value' option in each text box with the value from the database? For example for one of the comment boxes:
<?php $comment = intval(mysqli_real_escape_string($dbcon, $_POST["comment"])); ?>
<td><textarea class='normal' rows='3' cols='100%' name='$cmntbox_name' id='$cmntbox_name' value = '$comment' ></textarea></td>
I think that $_POST
only works on a page redirected from a submit button, so when a user is opening a saved form, should the button/link to open the form be a submit type button?
Upvotes: 0
Views: 2110
Reputation: 14064
In this scenario. What you have suggested is a nice way to go ahead. Lets say you have long form to fill in. First of all change a single big form to multiple small forms. dividing the form into pages can help increase conversion because: it can make the first step less daunting; can minimize the chance of data being lost mid-complete; and can make the overall process seem simple.
So the very first info which you collect might be his name, username and password. so that he can login back and fill his details and yes you need to fill in the 'value' option in each text box with the value from the database, when the user logins back
To get the values from the database and show it in the text-boxes will help you to partially filled form and continue filling it at a later time. For the same you can use either 1 table and run update command every-time user saves the data or you might have multiple table with a auto unique-id provided to each user. Whatever suits your requirement.
Upvotes: 0