我与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