12
I have a problem with my code to separate logins. I want when a login with Rank = 1
it redirects to a page, and when the Rank
is = 0
go to another. I tried to do it but I didn’t get it because he always sends it to the same one. How to solve it?
<?php
require_once 'config.php';
$userName = $_POST["user-name"];
$userPass = $_POST["user-pass"];
$criptSen = hash("whirlpool", $userPass);
@$rediURL = $_GET["url"];
$SQL = mysql_query("SELECT Usuario, Senha FROM utilizadores WHERE Usuario='$userName' AND Senha='$criptSen'");
$query = mysql_query($SQL);
while($row = mysql_fetch_array($query)){
$rank = $row["Rank"];
}
if(mysql_num_rows($SQL) != 0){
session_start();
$_SESSION['Usuario'] = $userName;
$_SESSION['Senha'] = $criptSen;
if($rank = 0){
header("Location: membro.php");
} elseif($rank = 1) {
header("Location: admin/index.php");
}
} else {
header("Location: index.php");
}
?>
Code to protect Internal Pages Rank = 1
@$Usuario = $_SESSION["Usuario"];
@$Rank = $_SESSION['Rank']
if(!(isset($Usuario) && isset($Senha))){
$url = explode("/", $_SERVER["REQUEST_URI"]);
header("Location: index1.php?url=$url[3]");
} else if(isset($Usuario) && isset($Senha)){
$SQL = mysql_query("SELECT Usuario, Senha FROM utilizadores WHERE Usuario='$Usuario' AND Senha='$Senha' AND Rank=1");
if(mysql_num_rows($SQL) == 0){
echo "<script>alert(\"Area Restrita\");</scrpit>";
header("Location: ../index.php");
}
}
?>
the change worked?
– Lucas Henrique