Michael Rosello
Michael Rosello

Reputation: 153

How to save form data when going to another page

I have a simple application form it is divided in 3 pages. What I want is when i fill up the 1st page, then when i go to another page the data is still there so I co go back to first page when I want to changes the data I inputted.

I tried saving it in session but I think that is not the right way to do it. any suggestions?

Upvotes: 1

Views: 1831

Answers (1)

Ali Green
Ali Green

Reputation: 609

As you post the page, set the values you post in session variables e.g.

<?php $_SESSION['name'] = $_POST['name']; ?>

Then in your input fields, check to see if the session is set & if so they display that. e.g.

<input type="text" name="name" value="<?php if (isset($_SESSION['name'])) { echo $_SESSION['name']; } " />

Make sure you start a session on each page you want to use them on!

<?php start_session; ?>

Upvotes: 2

Related Questions