ログインページがあります。メインブランチおよびその他の管理者B、C、およびブランチB、C、およびDの管理者Aです。管理者Aはすべてのブランチにログインでき、管理者B、CおよびDは自分のブランチにのみログインできます。しかし、今私ができることは、すべての管理者だけが自分のブランチにログインできることです。どうすれば管理者AもブランチB、C、Dにログインできますか?2つの異なる条件のログインフォーム
これは私のコードです。
if($_POST['username'] && $_POST['password'] && $_POST['txtbranch']) {
$username = $_POST['username'];
$password = $_POST['password'];
$txtbranch = $_POST['txtbranch'];
$hash_pass = $password;
$query = mysqli_query("select * from sysfile where username='".$username."' and password='".$hash_pass."' and branchid='".$txtbranch."' limit 1");
$count_user = mysqli_num_rows($query);
if($count_user==1)
{
$row = mysqli_fetch_array($query);
$_SESSION['userid'] = $row['userid'];
$_SESSION['username'] = $row['username'];
$_SESSION['pin'] = $row['pin'];
$_SESSION['branchid'] = $_POST['txtbranch'];
header("location:dashboard.php?success=1");
}else{
$error = 'Incorrect Username, Password and Branch.';
}
}
'管理A'はユーザー名ですか?あなたはSQLインジェクションに開放されており、パスワードをハッシュ化しておく必要があります。 – chris85
実際にハッシュしますか?変数名を変更してもハッシングはありません。 – chris85
あなたにはうれしいかもしれません。準備されたステートメントを使用して、パスワードをハッシュして前進させる方法を学んでください:http://php.net/manual/en/mysqli.prepare.php、http://php.net/manual/en/pdo.prepared-statements .phpとhttp://php.net/manual/en/function.password-hash.php、http://php.net/manual/en/function.password-verify.php –