PHP FORMS and $_SESSIONS

This is a discussion on PHP FORMS and $_SESSIONS within the PHP Language forums, part of the PHP Programming Forums category; i have a 7 page form and many many many variables.. i cant figure out how to get the variables ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-11-2004
quinonez@gmail.com
 
Posts: n/a
Default PHP FORMS and $_SESSIONS

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

Reply With Quote
  #2 (permalink)  
Old 12-11-2004
Jan Pieter Kunst
 
Posts: n/a
Default Re: PHP FORMS and $_SESSIONS

quinonez@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, <devnull@cauce.org> is een "spam trap".
E-mail adres is <jpk"at"akamail.com>, waarbij "at" = @.
Reply With Quote
  #3 (permalink)  
Old 12-11-2004
Quinonez
 
Posts: n/a
Default Re: PHP FORMS and $_SESSIONS

i keep gettin and error with that code also would like to know how to
do it through $_SESSION

Reply With Quote
  #4 (permalink)  
Old 12-11-2004
Chung Leong
 
Posts: n/a
Default Re: PHP FORMS and $_SESSIONS

<quinonez@gmail.com> wrote in message
news:1102780589.525949.105070@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;


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 09:21 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0