I'm using Generic HTML Form Processor in combination with an xampp lite installation to save data into a MYSQL database. However, I've encountered a problem while writing a multi-page survey. If users use the previous and forward buttons coded like:
<INPUT TYPE="button" VALUE="Previous Page" onClick="history.go(-1);">
<input type="submit" value="Go to last page">
The next button differs slightly per page. For example, on page 1 it's:
<input value="Next Page" type="submit">
Users can go back and forth in the survey. I would prefer them to use the backwards and forward button to let the browser take care of saving the data but sadly it's not an option. The next button is linked to a hidden input code like:
<input type="hidden" name="next_page" value="http://localhost/quislast.html">
It works like a dream except for one problem. Imagine there are three pages, A, B, and C. If a user is on page C, and they click the previous button twice so they return to page A. If they then click the next page button, the form data (radio butt开发者_如何学Cons) that the users select on pages B and C are no longer remembered. The users then have to re-select their answers before submitting the form.
Any ideas? Thank you in advance. And I apologize if the answer is so simple a novice could understand it.
Use a Session to collect the data during the survey. Then, when the user goes back and forth through the pages, fill in the input value attributes from the collected values in the $_SESSION
array. When the user is finished with the survey, save the data to the database.
精彩评论