John Taylor-Johnston wrote:
Hey, I dont know how much easier it will be but it is faster, you could use a switch statement.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>"; }
switch ($_SESSION['familyname'])
{
case 'name1':
do something;
break;
case 'name2':
do something;
break;
default:
do this if the variable doesnt match a case;
break;
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php