Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi! I want to create login from multiple table like there are three table admin,employee and CRM. When they will enter their username and password it will check their department and will open the page responding that. like if admin put their username and password it will open admin/index.php page.

I have created one user login page but having problem now in creating multiple user login.

my one user login is like that....

PHP
$sql="SELECT username, password FROM admin where username='".$username."' and password='".$password."'";
$result=mysqli_query($conn,$sql);

// Mysql_num_row is counting table row
$count=mysqli_num_rows($result);

// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){

// Register $myusername, $mypassword and redirect to file "login_success.php"
$_SESSION['username'] = $username;
$_SESSION['password'] = $password;
header("location:admin/index.php");
}
else {
echo "Wrong Username or Password";
}
Posted

1 solution

Please go through the following steps

1. You will have to retrieve the department of the user who has logged into the system.
2. Check the department with the departments you have and depending on the match show him the appropriate page.

Hope the above steps help you solve your problem.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900