Handling data of multipage form when going to previous pages

Hello

I have a multi page HTML form, I am handling its data using PHP sessions, so as I go next with the pages, I store the GET or POST data in the session and so on. The next buttons are obviously submit buttons with a target. Everything is good so far; however, what if I am clicking back rather than next, how can I get this data with me to the previous page and store it in the sessions, the previous button is obviously not a submit button, because we can’t have two submit buttons in a single form.

Thank you

The pagination solution I found and have modified to fit my work has the back button in a link. The next button is also a link. The link is created by the script seting the previous page as the current page -1 for back and +1 the next page. Neither of the links are submit.

Since my pages are created by a script that loops through the code a specified number of times (say 5), I know that page 4 starts with row 20 and ends with row 24 from my database. thus page 4-1 starts with row 15 and ends with row 19, and page 4+1 starts with row 25 and ends with row 29.

There may be other ways, but most of what I found with a Google search on PHP pagination came up with similar solutions.

Thank you for your reply.
However, what I am looking for is not pagination which fetch data from database and display X number of rows. My case is a multiple page PHP form, so each page is a stage of an interrelated form.
However, if I go next, I should keep the data of the page I am leaving someway, thus I store it in the session. The problem is when going back; there is no way to send the data.

One way would be to store their submissions in the database every time they click ‘Next Page’ - i.e. the Next Page button is an actual submit button. Then, the back button is a just a link to a previous page - when this page is generated, PHP should check the database for any previously submitted responses and pre-fill the form. You will need to use sessions (or similar) to track the user (i.e. give them a user-id which is stored in the database with any responses). When they have filled in all the survey and clicked the Submit button on the last page, their responses could be flagged as ‘finalised’ in the database.

Using $_POST, you could fill the value in your form with something like:

<input type=“text” name=“address” size=“40” maxlength=“40” value=“<?php if (isset($_POST[‘address’])) echo $_POST[‘address’]; ?>” />

because we can’t have two submit buttons in a single form.

Yes you can.

<input type=‘submit’ name=‘submit’ value=‘Go Back’ />
<input type=‘submit’ name=‘submit’ value=‘Submit’ />

On the form receiver, if $_POST[‘submit’] == ‘Go Back’ then send them back, this allows you to also store any partial info they filled on the current form, making your user happy to not have to refill.