I haven't followed the rest of the thread, but how about using a
function?
function getvar ($varname)
{
if (isset ($_POST[$varname])
{
$_SESSION[$varname] = $_POST[$varname];
return $_POST[$varname];
}
elseif (isset ($_SESSION[$varname]))
return $_SESSION[$varname];
}
session_start();
// You don't need session_register anymore
$familyname = getvar('familyname');
and so on--just one line per variable.
Hope this helps.
Cheers,
Marco
--
------------
php|architect - The Magazine for PHP Professionals
The monthly magazine dedicated to the world of PHP programming
Check us out on the web at http://www.phparch.com!
--- Begin Message ---
>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
--- End Message ---
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php