* Thus wrote Ryan A ([EMAIL PROTECTED]):
>
> foreach ($vars as $key) // clear all previous sessions
> {
> if(isset($_SESSION['$key']))
> {
> unset($_SESSION['$key']);
> }
> }
> echo "done1"; //just checking program execution
No need to loop here, you can use an else statment in the next
loop. And the key is inside '' as John pointed out.
>
> foreach ( $vars as $vvvv ) // if any checkboxes were checked create a
> session for them
> {
> ${$vvvv} = ( isset($_POST[$vvvv]) ? 1 : 0 );
>
> if($vvvv==1)
> {
> $_SESSION[$vvvv];
> echo $vvvv; //getting no output from here...I just put it here for
> testing
> }
> }
Couple things:
. Try not to use abstract names for vars (ie $vvvv), it makes the
code harder to understand what its doing. But since this is a
test script I'll let that slide :)
. Your ${$vvvv} assingment is never used, read up on how to use
variable variables. It isnt and shouldn't be used in this
instance.
. Try and make things a little simpliler:
foreach ($vars as $vvvv)
{
if ( isset($_POST[$vvvv]) )
{
$_SESSION[$vvvv] = 1; // be sure to assign a value.
}
else
{
unset($_SESSION[$vvvv]); // no single quotes around the key
}
}
HTH,
Curt
--
"I used to think I was indecisive, but now I'm not so sure."
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php