Connecting Tech Pros Worldwide Forums | Help | Site Map

$_SESSION=$_POST

Quinonez
Guest
 
Posts: n/a
#1: Jul 17 '05
if i set a $_SESSION=$_POST in every page of a multiple page form how
then would i call it on a later page of the same session? and also how
is distigushed between pages ? should it be set up differently on each
page, ive read of
$_SESSION['variablename']=$_POST
but i cant seem to figure out how to call it back at the end of the form


LB
Guest
 
Posts: n/a
#2: Jul 17 '05

re: $_SESSION=$_POST


Quinonez wrote:[color=blue]
> if i set a $_SESSION=$_POST in every page of a multiple page form how
> then would i call it on a later page of the same session? and also how
> is distigushed between pages ? should it be set up differently on each
> page, ive read of
> $_SESSION['variablename']=$_POST
> but i cant seem to figure out how to call it back at the end of the form
>[/color]
it's called back using echo $_SESSION['variable']...that simple
Quinonez
Guest
 
Posts: n/a
#3: Jul 17 '05

re: $_SESSION=$_POST


here is an example of my code:
=======resources_a6.php=====
<?
session_start();
header("Cache-control: private");
$_SESSION['resources_a6'] = $_POST;
?>
<html>
<head>
<title>2004 APPLICATION FOR AFFILIATION</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<link href="forms.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#000000" leftmargin="0" topmargin="0">
<form action="resources_a7.php" method="post">
..................
// then my form and submit button are here so on and so on

======resources_a7.php==========
<?
session_start();
header("Cache-control: private");
$_SESSION['resources_a7'] = $_POST;
?>
<html>
<head>
<title>2004 APPLICATION FOR AFFILIATION</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<link href="forms.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#000000" leftmargin="0" topmargin="0">
<form action="testthis.php" method="post">
..................
// then my form and submit button are here so on and so on

=============testthis.php========
<?
session_start();
header("Cache-control: private");
?>
<html>
<body>

<?
foreach($_POST as $field=>$value)
{
echo "$field = $value<br>";
}
?>


</body>
</html>

How do i change this to display correctly? currently it will only
display the last page

LB
Guest
 
Posts: n/a
#4: Jul 17 '05

re: $_SESSION=$_POST


Quinonez wrote:[color=blue]
> here is an example of my code:
> =======resources_a6.php=====
> <?
> session_start();
> header("Cache-control: private");
> $_SESSION['resources_a6'] = $_POST;
> ?>
> <html>
> <head>
> <title>2004 APPLICATION FOR AFFILIATION</title>
> <meta http-equiv="Content-Type" content="text/html;
> charset=iso-8859-1">
> <link href="forms.css" rel="stylesheet" type="text/css">
> </head>
> <body bgcolor="#000000" leftmargin="0" topmargin="0">
> <form action="resources_a7.php" method="post">
> .................
> // then my form and submit button are here so on and so on
>
> ======resources_a7.php==========
> <?
> session_start();
> header("Cache-control: private");
> $_SESSION['resources_a7'] = $_POST;
> ?>
> <html>
> <head>
> <title>2004 APPLICATION FOR AFFILIATION</title>
> <meta http-equiv="Content-Type" content="text/html;
> charset=iso-8859-1">
> <link href="forms.css" rel="stylesheet" type="text/css">
> </head>
> <body bgcolor="#000000" leftmargin="0" topmargin="0">
> <form action="testthis.php" method="post">
> .................
> // then my form and submit button are here so on and so on
>
> =============testthis.php========
> <?
> session_start();
> header("Cache-control: private");
> ?>
> <html>
> <body>
>
> <?
> foreach($_POST as $field=>$value)
> {
> echo "$field = $value<br>";
> }
> ?>
>
>
> </body>
> </html>
>
> How do i change this to display correctly? currently it will only
> display the last page
>[/color]
ok, first make sure you have a variable in $_POST (ie $_POST['name'])
then you can append values by using .= however it looks like your trying
to set the session variable to an array and to be honest i'm not
entirely sure how to had value to an array.. start at php.net with 'add
values array' or similar...hope that helps

Erick
Quinonez
Guest
 
Posts: n/a
#5: Jul 17 '05

re: $_SESSION=$_POST


no actually that wasnt what i was looking for...i have looked through
the groups and found that w. a mulitple page form all i had to do was
set it as $_SESSION=$_POST but after that i do not know what to do...

Ken Robinson
Guest
 
Posts: n/a
#6: Jul 17 '05

re: $_SESSION=$_POST



Quinonez wrote:[color=blue]
> here is an example of my code:[/color]

[snip]
[color=blue]
>
> =============testthis.php========
> <?
> session_start();
> header("Cache-control: private");
> ?>
> <html>
> <body>
>
> <?
> foreach($_POST as $field=>$value)
> {
> echo "$field = $value<br>";
> }
> ?>
>
>
> </body>
> </html>
>
> How do i change this to display correctly? currently it will only
> display the last page[/color]

Here's one way...
In each of your processing programs:
<?
$_SESSION['processed'][] = $_POST;
?>

In testthis.php:
<?
for ($i=0;$i<count($_SESSION['processed']);$i++)
foreach ($_SESSION['processed'][$i] as $field => $key)
echo "$field = $value<br>";
?>

Note: this code is untested, so it may not work.

Ken

Pedro Graca
Guest
 
Posts: n/a
#7: Jul 17 '05

re: $_SESSION=$_POST


Quinonez wrote:
<snip>[color=blue]
>=============testthis.php========
> <?
> session_start();
> header("Cache-control: private");[/color]

$_SESSION['testthis'] = $_POST;
[color=blue]
> ?>
> <html>
> <body>
>
> <?
> ## foreach($_POST as $field=>$value)
> ## {
> ## echo "$field = $value<br>";
> ## }[/color]

echo '<pre>'; print_r($_SESSION); echo '</pre>';

or

foreach ($_SESSION as $page=>$post) {
echo "<h1>$page</h1>";
foreach ($post as $field=>$value) {
echo "$field = $value<br>";
}
}
[color=blue]
> ?>
>
>
> </body>
> </html>
>
> How do i change this to display correctly? currently it will only
> display the last page[/color]

The $_POST array only has the last submitted page.
You need to use the $_SESSION array.


Happy Coding :-)

--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!
g18c@hotmail.com
Guest
 
Posts: n/a
#8: Jul 17 '05

re: $_SESSION=$_POST


May not be of interest (and indeed this may be wrong but it works for
me) - Using PHP PEAR quickform

if($form->validate())
{
$_SESSION = array_merge($_SESSION,$form->exportValues());
}

appends the form variables to the session. Then knowing the names of
the fields i access them by $_SESSION['name']

Chris

Ken Robinson
Guest
 
Posts: n/a
#9: Jul 17 '05

re: $_SESSION=$_POST



Quinonez wrote:[color=blue]
> no actually that wasnt what i was looking for...i have looked through
> the groups and found that w. a mulitple page form all i had to do was
> set it as $_SESSION=$_POST but after that i do not know what to do...[/color]

If you don't know what to do, then first you have to see what you put
in the $_SESSION array. In each program, after you do the
$_SESSION=$_POST, dump the contents of $_SESSION by doing

echo '<pre>';print_r ($_SESSION); echo '</pre>';

After you see the contents, you should be able to figure out what to
do.

Ken

Quinonez
Guest
 
Posts: n/a
#10: Jul 17 '05

re: $_SESSION=$_POST


thanks all...i finally got it to work ..with answers here and there...

Closed Thread


Similar PHP bytes