我需要一些关于重定向的帮助。我有这段代码,想将用户重定向到特定页面。包含用户名和密码的表还包含第三条数据,即组织名称。每个组织都有自己的页面。--我在第 17 行添加了一家公司的名称,但我一直在底部得到回声。任何帮助都会很棒。
$dbc = dbConnect();
$username = "exampleuser";
$sql = "SELECT 'password' from users where 'username' = '$username';";
$result = mysql_query($sql, $dbc); //run the query
if ($result)
{
$row = mysql_fetch_assoc($result);
$password = $row['password'];
// echo '<h2>Result Found '.$password.'</h2>'.PHP_EOL;
$myPassword = $_POST['password'];
$row = mysql_fetch_assoc($result);
//$password = $row['password'];
//match passwords
if($myPassword == $password){
//Decide where to send user depending on company column:
$privilege = $row['company'];
if($privilege == "companyname"){
header( 'Location: admin1.php' );
}
if($privilege == "user"){
header( 'Location: user.php' );
}
if($privilege == "other"){
header( 'Location: other.php' );
}
exit; //This tells php to stop executing as soon as we redirect
}else{
echo "Wrong username/password, try again";
}
}