By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,722 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

PHP FORMS and $_SESSIONS

P: n/a
i have a 7 page form and many many many variables..
i cant figure out how to get the variables to move from each page and
show after it is submitted. I can get the last page of the form to show
on the action page but not any of the other pages before that.

Should i be entering every single variable from each page into a
$_SESSION['varname']

or is there an easy way to do it..
the script i am using on the action page is:

<?
foreach ($_POST as $_SESSION['field'] => $value)
{
echo "$field: $value<br>";
}
?>

and that works for the last page of the form but not anyother?
please help
Thanks

Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
qu******@gmail.com wrote:
i have a 7 page form and many many many variables..
i cant figure out how to get the variables to move from each page and
show after it is submitted. I can get the last page of the form to show
on the action page but not any of the other pages before that.

Should i be entering every single variable from each page into a
$_SESSION['varname']


That's a possibility. You could also echo all variables from the
previous page in hidden fields in the next page, like this:

foreach ($_POST as $varname => $value) {

$value = function_you_should_write_to_escape_value($value);
echo "<input type=\"hidden\" name=\"$varname\" value=\"$value\" /> ";
}

Note that you can't have variables with the same name on different pages
if you use this technique.

HTH,
JP

--
Sorry, <de*****@cauce.org> is een "spam trap".
E-mail adres is <jpk"at"akamail.com>, waarbij "at" = @.
Jul 17 '05 #2

P: n/a
i keep gettin and error with that code also would like to know how to
do it through $_SESSION

Jul 17 '05 #3

P: n/a
<qu******@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
i have a 7 page form and many many many variables..
i cant figure out how to get the variables to move from each page and
show after it is submitted. I can get the last page of the form to show
on the action page but not any of the other pages before that.

Should i be entering every single variable from each page into a
$_SESSION['varname']

or is there an easy way to do it..
the script i am using on the action page is:

<?
foreach ($_POST as $_SESSION['field'] => $value)
{
echo "$field: $value<br>";
}
?>

and that works for the last page of the form but not anyother?
please help


The more orthodox approach is to use hidden form fields. The easiest way to
do this is to save the $_POST array of each submit in $_SESSION.

form1.php:

$_SESSION['form1'] = $_POST;

form2.php:

$_SESSION['form2'] = $_POST;
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.