网上购物的多重登录 if(空($\u POST)==false){ $email=$_POST['email']; $password=md5($_POST['password']); 如果(空($email)==true | |空($password)==true){ $errors='请填写两个字段:'; } 其他的 { $select=mysqli_查询($conn,“select*from user”); $login=mysqli\u fetch\u数组($select); 如果($login['email']==$email&$login['password']==$password&& $login['user_type']=='Admin'){ $\会话['email']=$email; 标题('location:Admin/index.php'); } 否则{ echo$\u会话['email']=$email; 标题('location:index.php'); } $errors='您不是管理员,请输入有效的电子邮件和密码'; } 让我登录 登录
* 此代码用于管理和用户登录面板,但它仅适用于管理 这是用于在线购物系统的,在哪里 下单需要用户id或电子邮件 它也不会在用户端显示会话变量网上购物的多重登录 if(空($\u POST)==false){ $email=$_POST['email']; $password=md5($_POST['password']); 如果(空($email)==true | |空($password)==true){ $errors='请填写两个字段:'; } 其他的 { $select=mysqli_查询($conn,“select*from user”); $login=mysqli\u fetch\u数组($select); 如果($login['email']==$email&$login['password']==$password&& $login['user_type']=='Admin'){ $\会话['email']=$email; 标题('location:Admin/index.php'); } 否则{ echo$\u会话['email']=$email; 标题('location:index.php'); } $errors='您不是管理员,请输入有效的电子邮件和密码'; } 让我登录 登录,php,mysql,Php,Mysql,* 此代码用于管理和用户登录面板,但它仅适用于管理 这是用于在线购物系统的,在哪里 下单需要用户id或电子邮件 它也不会在用户端显示会话变量 *在else部分中,使用以下条件检查尝试登录的人是否为管理员/用户 if (empty($_POST) === false) { $email=$_POST['email']; $password= md5($_POST['password']); if (empty($email) === true || empty($password) ===
*在else部分中,使用以下条件检查尝试登录的人是否为
管理员/用户
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>
在用户类型中,我刚刚提到它是user(作为一个例子)
。您需要在db中键入您正在使用的确切用户类型。老实说,这里有很多错误。但是对于初学者来说…(1)您只检查user
表中的第一条记录。肯定有更多的用户?(2)您只检查登录是否正确,用户是否是管理员。对于任何其他情况(如不正确的登录),您假定他们是有效用户。
else {
if($login['email'] ==$email && $login['password'] == $password &&
$login['user_type']== 'user'){
$_SESSION['email']=$email;
header('location:index.php');
}