Login form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kimimf1993
Forum Newbie
Posts: 1
Joined: Fri Jul 28, 2017 12:48 am

Login form

Post 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
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Login form

Post 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.
Post Reply