Page 1 of 1

Login form

Posted: Fri Jul 28, 2017 1:05 am
by kimimf1993
hi
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.';	
		}
}

thanks

Re: Login form

Posted: Fri Jul 28, 2017 5:15 am
by Celauran
You will need some way to keep track of who has access to what. This can be as simple as creating some sort of 'super user' flag to denote accounts having access to everything, or implementing some sort of ACL.