Reputation: 253
When a user hits log in button on a page in order to verify heres what i need to do:
1st check if they exist and their login info is valid in the members table.
2nd using the entered username now check if they have access to this speficif page by checking the access table with their username.
i have to tables members and access.
Members has the following: id, username, password
Access has the following: userid, companyid
So say my username= ASH and password= 14ash
I'm trying to login to view a specific restricted page for the company called TARGET.
I first login with my account info with username ASH & password 14ash in php i check the database table called members with mysql to see if i exist
and at the sometime i check the ACCESS table using access.userid = ASH & access.companyid= TARGET
once all is check if i exist in both tables then i let the user login.
I tried this but doesn't work.
$sql="SELECT * FROM access,members
WHERE members.username='$myusername'
AND members.password='".md5($mypassword)."')
OR (access.userid=members.username
AND access.companyid='$username')";
Upvotes: 1
Views: 64
Reputation: 861
It should be
sql="SELECT * FROM access,members WHERE members.username='$myusername'AND members.password='".md5($mypassword)."' AND access.userid=members.id";
Upvotes: 1