Variable always stuck as True???????
Posted: Thu Jan 13, 2005 6:52 pm
Here is my php script... it's supposed to create a session and be used throughtout my site to remember if the user choose Broadband or Dialup so I can when neccesary have the PHP print the hyperlink that is most suitable for their bandwidth.
The problem is that the variable is always passed as true.
Someone helped me make this code on a different forum and is talking to me like I have any idea of how to do anything besides create a static variable or how to set an includes.
For me to learn from this I have to be able to compare apples to oranges so if you just post a snippet of code I wont progress at all. I think this has to do with index2.php as I put that code together ... so if it is please post the full PHP code for that page and if his cde is bad please post the full PHP code for those file.
INDEX.PHP
__________
<?php include("config.php");
if($_GET['bb'] == false)
{ unset($_SESSION['bb']); } ?>
<html><head></head><body>
<a href="index2.php?bb=true">Broadband</a> ~ <a href="index2.php?bb=false">Dial-Up</a>
</body></html>
CONFIG.PHP
__________
<?
session_start();
if($_GET['bb'] == false)
{
unset($_SESSION['bb']);
}
if (empty($_GET['bb']) && empty($_SESSION['bb']))
{
$_SESSION['bb'] = false;
}
else
{
$_SESSION['bb'] = true;
}
?>
INDEX2.PHP
__________
<html>
<head>
</head>
<body>
<?php include("config.php");
if ($_SESSION['bb'] == true)
{
echo 'Broadband';
}
else {
echo 'Dialup';
}
?>
</body>
</html>
The problem is that the variable is always passed as true.
Someone helped me make this code on a different forum and is talking to me like I have any idea of how to do anything besides create a static variable or how to set an includes.
For me to learn from this I have to be able to compare apples to oranges so if you just post a snippet of code I wont progress at all. I think this has to do with index2.php as I put that code together ... so if it is please post the full PHP code for that page and if his cde is bad please post the full PHP code for those file.
INDEX.PHP
__________
<?php include("config.php");
if($_GET['bb'] == false)
{ unset($_SESSION['bb']); } ?>
<html><head></head><body>
<a href="index2.php?bb=true">Broadband</a> ~ <a href="index2.php?bb=false">Dial-Up</a>
</body></html>
CONFIG.PHP
__________
<?
session_start();
if($_GET['bb'] == false)
{
unset($_SESSION['bb']);
}
if (empty($_GET['bb']) && empty($_SESSION['bb']))
{
$_SESSION['bb'] = false;
}
else
{
$_SESSION['bb'] = true;
}
?>
INDEX2.PHP
__________
<html>
<head>
</head>
<body>
<?php include("config.php");
if ($_SESSION['bb'] == true)
{
echo 'Broadband';
}
else {
echo 'Dialup';
}
?>
</body>
</html>