Forum Moderators: coopster

Message Too Old, No Replies

handling multi page forms

         

surrealillusions

5:46 pm on Sep 24, 2009 (gmt 0)

10+ Year Member



Hi all,

I would like to build a form/script that can carry data over 2 or 3 pages. I've looked up on google, and it seems the best way is to use sessions.

But im unsure on how it works.

I've figured out you need to do this when submitting the form (Which is done on the same page as the form).


// create a session to put stuff into, to store over 2 pages
session_start();

// Fill it with our post vars
$_SESSION['name'] = $_POST['name'];
$_SESSION['email'] = $_POST['email'];
$_SESSION['stuff'] = $_POST['stuff'];

Then when all is ok with the input, its then sent to another page. On this page is where I kinda get stuck, how do i call those values back again? And how do i use them to insert back into another form if need be?

Thanks

:)

d40sithui

6:09 pm on Sep 24, 2009 (gmt 0)

10+ Year Member



See below. I think this will help you.
how do i call those values back again?

<?
session_start();
echo $_SESSION['name'];
echo $_SESSION['email'];
echo $_SESSION['stuff'] ;
?>

And how do i use them to insert back into another form if need be?

<form action="formActionScript.php" method="POST">
<input type="text" name="myName" value="<? echo $_SESSION['name']; ?>">
<input type="text" name="myEmail" value="<? echo $_SESSION['email']; ?>">
<input type="text" name="myStuff" value="<? echo $_SESSION['stuff']; ?>">
</form>