3
I have a login system in a program PHP
that I want it to forward users to different pages depending on their profile. There is a login table that has a field called "perfil
" who is either 0
or the 1
. The goal is to route users depending on their profile to different pages. How can I do it in a simple way?
<?php
include ("incs/ligacao.inc.php");
include('session.php');
$user_check=$_SESSION['login_user'];
session_start();
$utilizador = $mysqli->query("SELECT perfil from login where username='$user_check'");
$result = $utilizador->fetch_assoc();
if($result['perfil'] == 0){
header('Location: menu.php');
}
elseif($result['perfil'] == 1){
header('Location:menu.php');
}
?>
Always stays on the login page when trying to do this check
Possible duplicate => http://answall.com/questions/35092/howto create a system-of-control-of-permiss%C3%B5es
– LucaoA
If you are an echo in $user what it returns?
– Fleuquer Lima
cannot check because of Session, but doing the query in mysql returns 1
– pdpc
The
fetch
. You’re comparing an object, so don’t enter theif
– Papa Charlie
but even with fetch it always goes back to the login page. I already entered fetch and still does not enter if
– pdpc
Update the issue with the use of
fetch
, show how it turned out.– Papa Charlie
with fetch gets this way, the problem is that when I enter user it always goes back to login page
– pdpc
Give a
var_dump( $result )
and say what comes up.– Papa Charlie
Hey, I have a login system very similar to yours in this question, if you want to use, will: https://answall.com/questions/241731/login-com-system-validate%C3%A7%C3%A3o
– Mariana Bayonetta