-1
我想允許用戶從兩個表使用一種形式登錄,檢查第一個表,如果用戶存在,如果它不存在它應該檢查其他表回聲用戶確實存在。我曾嘗試以下,但它不工作允許用戶登錄使用不同的表中的數據
<?php$username = $DBcon->real_escape_string($username);
$email = $DBcon->real_escape_string($email);
$password = $DBcon->real_escape_string($password);
$hash = password_hash($password, PASSWORD_DEFAULT);
$get = "SELECT _userid, u_name, hemail, pass_word from five_thousand where hemail='$email' or u_name='$username' limit 1";
$get2 = "SELECT _userid, u_name, hemail, pass_word from ten_thousand where hemail='$email' or u_name='$username' limit 1";
// for five thousand
$drup = $DBcon->query($get);
$row=$drup->fetch_array();
// for ten thousand
$drup2 = $DBcon->query($get2);
$row2 = $drup2->fetch_array();
if ($row['hemail'==1]) {
if ($row['pass_word'] == $hash) {
$_SESSION['userSession'] = $row['user_id'];
header("Location: ../office.php");
}else {
$msg = "<div class='alert alert-danger'>
<span class='glyphicon glyphicon-info-sign'></span> Invalid Username or Password !
</div>";
}
}
elseif ($row2['hemail']==1) {
if ($row['pass_word'] == $hash) {
$_SESSION['userSession'] = $row['user_id'];
header("Location: ../office.php");
}else {
$msg = "<div class='alert alert-danger'>
<span class='glyphicon glyphicon-info-sign'></span> Invalid Username or Password !
</div>";
}
}else{
echo "user does not exixt";
}
$DBcon->close();
?>