Previous button in HTML / PHP
I thought about this problem, but I haven't come to any conclusion. My problem here is that I need a Previous button added to the form. The user must fill out a form that is divided into 13 parts. Each part is its own form, with a Next button to send everything to the database and redirect to the next page.
How do I enable the Previous button? ...
I don't want it to be helpful for you to know that I am using cakePHP, and it's a good thing that I'm pretty new to it.
a source to share
I coded a similar form in classic ASP, see if you can get it to work in CakePHP:
I had a 7 step form, step 2-7 had the previous buttons. Each step consists of one asp script. All scripts are sent back to themselves. I check REQUEST_METHOD
on every script call to see if it was called by a method GET
or POST
. If POST
, then the data is checked, if they are checked, then they are saved. Forms have three submit buttons that allow the user to choose whether they just want to save the data, save and go to the next step, or save and go to the previous step. Depending on which button was clicked, the user is redirected to the previous / next page. This post points out how to add and handle the previous / next buttons:
a source to share
Save the POST data of each form and the current index of the form in the session. On clicking the back button, open the form (currentForm - 1)
(if it is a valid form index) and fill in the fields with formData[currentForm]
(assuming currentForm is now the form that the back button was redirected to)
a source to share
The question is, do you want to store each step of the formula in a record? or do you want to store each step of the formula in a "transaction"? The difference is important here. What is your relationship with the user? Sign in? are they anonymous? How do you link their responses from one form entry to the next? If you are storing each record in the database in some chronological way, simply fill out the previous form with the previously entered values; when they click previous. If you are not storing records and are instead using a session to store values between "next" clicks, fill out this "previous" form with those values.
a source to share