When faced with this problem I tried the following (works)
The top section of PHP code just reads the POST return array
and plops it into a series of successive _SESSION vars
Included is a FORM to use that shows the simple code at work
HTH
TomHenry
================ Tested =================
<?
session_start();
//echo "<HR>List the _POST key/val pairs<P>";
// Try to cycle though the _POST vars
// and use them as input to creating _SESSION vars
while(list($k,$v)=each($_POST)){
$_SESSION[$k]=$v;
//echo "_name_ <b>".stripslashes($k)."</b> _value_ <b>".stripslashes($v)."</b><br>";
}
// easy way to peek at the contents of what we just did
echo "<hr>print_r of the \$_SESSION array<P>";
print_r($_SESSION);
echo "<hr>";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Nextpage</title>
</head>
<body>
<P><HR><P>
<b><u>Is our _SESSION here?</u></b>
<P>
<Table width=60% border=1 cellspacing=0 cellpadding=5>
<TR><TH>Key</TH><TH>Value</TH></TR>
<?
while(list($k,$v)=each($_SESSION)){
echo "<TR><TD>".stripslashes($k)."</TD><TD>".stripslashes($v)."</TD></TR>";
}
?>
</TABLE>
<P><HR><P>
<form action=<?=$PHP_SELF?> method=POST>
key <input type="text" name="key" value='KeyOne' size="15" maxlength="25"> -- value <input type="text" name="value" value='ValueOne' size="30" maxlength="80">
<br>
Name: <input type='text' name='name' value="Tim O'Toole " size='12'> -- Address: <input type='text' name='address' value='123 Main Street'>
<input NAME=action type=submit value="Submit">
</form>
<P><HR><P>
</body>
</html>
John Taylor-Johnston wrote:
Jason wrote: RTFM again.Jason, again, I RTFM, but did not get it working. Otherwise I wouldn't have dared ask a question.Sessions depends on a number of factors including your version of PHP and the setting of register_globals.The FM manual says: "$_SESSION (or $HTTP_SESSION_VARS with PHP 4.0.6 or less) is recommended" So I am using "PHP Version 4.1.2" (and "4.2.3" on my localhost to test offline) Ok. I quit using $HTTP_POST_VARS["familyname"]. With a little rethinking, I have this working, I hope. Now ... is there a cleaner way to assign my variable "familyname"? Pseudo code: if _post["familyname"] exists set session variable (no sense in setting it until I post it) if _session["familyname"] exists, $familyname = $_SESSION["familyname"]; I'll have about 30 variables. Going to be alot of lines. There must be an easier, cleaner way? <?php #session_name("TestALS"); session_start(); if (isset($_POST["familyname"])) { session_register("familyname"); $familyname = $_POST["familyname"]; echo "Yay: \$familyname= $familyname<br>"; } if (isset($_SESSION["familyname"])) { $familyname = $_SESSION["familyname"]; echo "yay session works, \$familyname= $familyname<br>"; }
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php