I am developing a simple login script by using PHP and SQL Server 2012 in which I want to validate username , password and my company code ..username and password are stored in same table but company code value is stored inside another table. My company code has some value which is CDSL and I only want those users to login who is writing CDSL in company code field likewise I also want only those users to login whose username and password is stored inside user_master table and in company code I want users to write CDSL but that value is stored inside another table which is company_master in company_master different company codes with company full name is stored in which I only want to take my company code which is CDSL I am sharing few lines of my code too
$uname = $_POST['user'];
$upassword = $_POST['pass'];
$company_code =$_POST['pos'];
$res = sqlsrv_query($conn,"select* from user_master where
UM_USERNAME='$uname'and um_pwd='$upassword' ");
UM_USERNAME is a column in which USERNAMES are stored and um_pwd is an column where users passwords are stored but inside this SQL statement I also want to include my company code which is stored inside company_master table and row name is CM_CODE where I wish to select value which is
$sql = "SELECT * FROM company_master where CM_CODE = 'CDSL'";
How can I merge above 2 SQL statements and for company code how can I give value $company_code inside CM_CODE I have already given CM_CODE= 'CDSL'