I have a login page. Admin A for main branch and other Admin B, C and for branch B, C and D. Admin A can login to all branch while Admin B, C and D only can login into their own branch. But now what I can do is all admin only can login into their own branch.
How can I do it so Admin A also can login into branch B, C and D?
This is my code.
Code: Select all
if($_POST['username'] && $_POST['password'] && $_POST['txtbranch']) {
$username = $_POST['username'];
$password = $_POST['password'];
$txtbranch = $_POST['txtbranch'];
$query = mysqli_query("select * from sysfile where username='".$username."' and password='".$password."' 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.';
}
}