how to deal with bool?
-
Hi, I have the following code to check if the user is_administrator then show the two menu items, otherwise of course it won't show... kindly simple! but the problem is.... when I uploaded the pages to my web host, even if the user is not administrator the menu items are shown! the value for is_administrator in MySQL is a bit = 0 but when I do a var_dump I get bool(true) although I get the correct var_dump and behavior on my local pc string(1) "0" this is the menu items:
<button id="btnManageUsers" type="button" style="width: 100%;">Manage Users</button>
<button id="btnNewUser" type="button" style="width: 100%;">New User</button>and this is the is_administrator:
while ($mysql_row = $mysql_query->fetch())
{
$_SESSION["blended_learning_user_name"] = $mysql_row["user_name"];
$_SESSION["blended_learning_is_administrator"] = $mysql_row["is_administrator"];exit(header("Location: " . $\_SESSION\["blended\_learning\_domain\_name"\] . "mypage"));
}
Technology News @ www.JassimRahma.com
-
Hi, I have the following code to check if the user is_administrator then show the two menu items, otherwise of course it won't show... kindly simple! but the problem is.... when I uploaded the pages to my web host, even if the user is not administrator the menu items are shown! the value for is_administrator in MySQL is a bit = 0 but when I do a var_dump I get bool(true) although I get the correct var_dump and behavior on my local pc string(1) "0" this is the menu items:
<button id="btnManageUsers" type="button" style="width: 100%;">Manage Users</button>
<button id="btnNewUser" type="button" style="width: 100%;">New User</button>and this is the is_administrator:
while ($mysql_row = $mysql_query->fetch())
{
$_SESSION["blended_learning_user_name"] = $mysql_row["user_name"];
$_SESSION["blended_learning_is_administrator"] = $mysql_row["is_administrator"];exit(header("Location: " . $\_SESSION\["blended\_learning\_domain\_name"\] . "mypage"));
}
Technology News @ www.JassimRahma.com
-
Hi, I have the following code to check if the user is_administrator then show the two menu items, otherwise of course it won't show... kindly simple! but the problem is.... when I uploaded the pages to my web host, even if the user is not administrator the menu items are shown! the value for is_administrator in MySQL is a bit = 0 but when I do a var_dump I get bool(true) although I get the correct var_dump and behavior on my local pc string(1) "0" this is the menu items:
<button id="btnManageUsers" type="button" style="width: 100%;">Manage Users</button>
<button id="btnNewUser" type="button" style="width: 100%;">New User</button>and this is the is_administrator:
while ($mysql_row = $mysql_query->fetch())
{
$_SESSION["blended_learning_user_name"] = $mysql_row["user_name"];
$_SESSION["blended_learning_is_administrator"] = $mysql_row["is_administrator"];exit(header("Location: " . $\_SESSION\["blended\_learning\_domain\_name"\] . "mypage"));
}
Technology News @ www.JassimRahma.com
Well, your problem is that you assign the value true to
$_SESSION["blabla"]
. I.e. it cannot work! SolutionA:SolutionB:
The difference between SolutionA and B is, that B also checks if
$_SESSION["bla"]
is of the same type as true, i.e. bool/boolean.