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

$_SESSION=$_POST

P: n/a
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

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


P: n/a
LB
Quinonez wrote:
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

it's called back using echo $_SESSION['variable']...that simple
Jul 17 '05 #2

P: n/a
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

Jul 17 '05 #3

P: n/a
LB
Quinonez wrote:
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

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
Jul 17 '05 #4

P: n/a
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...

Jul 17 '05 #5

P: n/a

Quinonez wrote:
here is an example of my code:
[snip]

=============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


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

Jul 17 '05 #6

P: n/a
Quinonez wrote:
<snip>
=============testthis.php========
<?
session_start();
header("Cache-control: private");
$_SESSION['testthis'] = $_POST;
?>
<html>
<body>

<?
## foreach($_POST as $field=>$value)
## {
## echo "$field = $value<br>";
## }
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>";
}
}
?>
</body>
</html>

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


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!
Jul 17 '05 #7

P: n/a
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

Jul 17 '05 #8

P: n/a

Quinonez wrote:
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...


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

Jul 17 '05 #9

P: n/a
thanks all...i finally got it to work ..with answers here and there...

Jul 17 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.