<?php
    include_once 'opendb.php';
   
   //print_r($_POST);
     $CompID=0;
     $ClientPass="";     
     $ClientCode="";
	 $mess="";
     if (isset($_POST["CompID"]))   {
        $CompID=$_POST["CompID"] ;
    }
    if (isset($_POST["ClientCode"]))   {
        $ClientCode=$_POST["ClientCode"] ;
    }
	if (isset($_POST["ClientPass"]))   {
        $ClientPass=$_POST["ClientPass"] ;
    }
    if ($ClientCode=='' || $ClientPass=='' || $CompID==0) {      
      $conn->close();
      die("Error : Parameters missing");  
    }    
    
   $sql = "SELECT inactive,app_pass,description FROM mobile_clients WHERE counter_code like '".$ClientCode."'  and comp_id=".$CompID;
    $result = $conn->query($sql);
    if ($result->num_rows > 0 ) {   
		if($row = $result->fetch_assoc()){    
			if ($row["app_pass"]==$ClientPass){
			   $mess =$row["description"];  //"LoginOK";			   
			} else {
				$mess = "Error: Incorrect Password";
			}				
			if ($row["inactive"]!=0)
			{
			   $mess = "Error: Inactive Account";
			}
		}            
    }     
    else {          
          $mess= "Error : Account Not Registered..!  : ".$ClientCode;
       }
    $conn->close();
    die( $mess);
   
?>