我與login.When這個PHP代碼我登錄爲「僱主」一切都ok.But當我作爲員工登錄它應該加載不同的page.It始終把它就像我的一個問題登錄爲「Employer.I想不通錯誤登錄錯誤PHP
<?php
session_start();
require_once('connection.php');
//Connect to server
$link = mysql_connect($host, $user, $pw) or die(mysql_error());
//Select the database
mysql_select_db ($db);
// Get the login credentials from user
$username = $_POST['Username'];
$userpassword = $_POST['Password'];
// Secure the credentials
$username = mysql_real_escape_string($_POST['Username']);
$userpassword = mysql_real_escape_string($_POST['Password']);
// Check the users input against the DB.
$query = "SELECT COUNT(`Username`) AS `total` FROM `users` WHERE `Username` = '$username' AND `Password` = '$userpassword'";
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);
if($row['total'] == 1)
{
if($Username='Employer')
{
$_SESSION['loggedIn'] = "true";
header("Location: indexemp.php");
}
}
elseif($Username='Employee')
{
header("Location: indexempl.php");
}
?>
請確保使用==標誌您正在使用=登錄if語句 –
您有'='而不是'==' – Neat