-3
if (empty($_POST) === false) {
$email=$_POST['email'];
$password= md5($_POST['password']);
if (empty($email) === true || empty($password) === true) {
$errors='Please fill both of the fields:';
}
else
{
$select= mysqli_query($conn,"select * from user ");
$login= mysqli_fetch_array($select);
if($login['email'] ==$email && $login['password'] == $password &&
$login['user_type']== 'Admin'){
$_SESSION['email']=$email;
header('location:Admin/index.php');
}
else {
echo $_SESSION['email']=$email;
header('location:index.php');
}
$errors='You are not admin please enter valid email and password';
}
<form action="" method="post">
<input type="email" placeholder="Email Address" name="email" />
<input type="password" placeholder="password" name="password" />
<span>
<input type="checkbox" class="checkbox">
Keep me signed in
</span>
<button type="submit" class="btn btn-default" name="login">Login</button>
</form>
用于管理员和用户登录面板,但其对管理
方只工作这个代码,而不是在用户侧,这是使用了网上购物系统在哪里是
用户名或电子邮件是必要的下订单 它也不显示会话变量在用户端 *
老实说,这里有很多*错误的东西。但对于初学者来说......(1)你只会检查'user'表中的第一条记录。当然有更多的用户? (2)您只检查登录是否正确*和*用户是管理员。对于任何其他情况(例如不正确的登录),您认为他们是有效的用户。 – David