php - how to combine two different queries?


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')";



It should be

sql="SELECT * FROM access,members WHERE members.username='$myusername'AND members.password='".md5($mypassword)."' AND";

People are also looking for solutions to the problem: html - PHP details and info about an IP


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.