<?php
session_start();
$conn=mysqli_connect('localhost','root','');
$name=$_POST['name'];
$password=$_POST['password'];
$UserType=$_POST['cmbUser'];
if ($UserType=="Admin")
{
mysqli_select_db($conn,"prison") or die("Cannot connect to database");
$sql = "select * from Admin_Tbl where name='".$name."' and
password='".$password."'";
$result = mysqli_query($conn,$sql);
$records = mysqli_num_rows($result);
$row = mysqli_fetch_array($result);
if ($records==0)
{
echo $records;
echo '<script type="text/javascript">alert("Wrong UserName or Password");
window.location=\'login2.php\';</script>';
}
else
{
header("location:adminpanel.php");
}
mysqli_close($conn);
}
else if($UserType=="Police")
{
mysqli_select_db($conn,"prison") or die("Cannot connect to database");
$sql = "select * from pol where name='".$name."' and
password='".$password."'";
$result = mysqli_query($conn,$sql);
$records = mysqli_num_rows($result);
$row = mysqli_fetch_array($result);
if ($records==0)
{
echo $records;
echo '<script type="text/javascript">alert("Wrong UserName or Password");
window.location=\'login2.php\';</script>';
}
else
{
$_SESSION['ID']=$row['Station_Id'];
$_SESSION['Name']=$row['Station_Name'];
header("location: officerpanel.php");
}
mysqli_close($conn);
}
?>
这是登录代码...管理员登录工作正常...但警方登录总是提供错误的用户名或密码错误,即使它是正确的!我已经在&#39; pol&#39;中添加了一个新用户。表使用存储过程....用户被添加到表但我无法使用该用户名和密码登录..请帮助!!