3
Hello guys I have this function if
it collects a variable coming from login.php and does a check to choose between two menus. It just doesn’t matter the result inside the variable $permt
he always chooses Isis. Someone can point out to me my mistake made.
<?php
include"in/login.php";
$hi=$svc['nome']."";
$permt=$svc['nivel']."";
?>
<?php
if($permt==1) {
require_once"in/menu.html";
echo "$permt";
}
else{
require_once"in/menu2.html";
echo "$permt";
}
?>
To complement this is the content of login.php
<?php
include "conecta.inc";
$log= mysqli_query($conn,"select nome,nivel from usuarios where login='$doc' ");
$svc=mysqli_fetch_array($log);
if($cont){
header("Location: ../home.php"); exit;
}
echo after receiving data in the $permt variable to see what is being received.
– Wilson Rosa Gomes
already made friend I get the expected value 1
– Danilo Araujo
There is no way of knowing, the problem lies elsewhere: http://ideone.com/dvrb5W
– Maniero
interestingly if I remove a sign of '=' it happens to show the first option, but hangs on it too.
– Danilo Araujo
try using quote or quote exe: ($permt=='1') or ($permt=="1") if it works is due to the type of information received being string and not integer.
– Wilson Rosa Gomes
Are you sure your
if
you’re not using ===?if($permt===1)
this condition plays to theelse
, but what you have in your code does not show error.– Papa Charlie
I did the tests suggested by Wilson same problem persists, only different thing is that I added echo within
if
andelse
and only occurs perfectly in if.– Danilo Araujo