<?php
	include_once('../config.php');   
    
          
     if($_POST['userDatacheck'])
     {    
          
            if (preg_match('/^[a-zA-Z]+[a-zA-Z0-9_]+$/', $_POST['Data'])) 
            {
            	$stmt = $conn->prepare("SELECT nm FROM UI__Rgst WHERE cuurentId=:cuurentId");  
                $stmt->execute(array(':cuurentId'=>$_POST['Data']));
        	    $Result = $stmt->fetch(PDO::FETCH_OBJ);      
        	    echo $Result->nm.", (Rs ".GetBalance($_POST['Data'])."/- )";
        		    
            } 
    		die;  
     }
     
     
      if($_POST['TopUpDatacheck'])
     {    
          
            if (preg_match('/^[a-zA-Z]+[a-zA-Z0-9_]+$/', $_POST['Data'])) 
            {
            	$stmt = $conn->prepare("SELECT cuurentId FROM UI__Rgst WHERE cuurentId=:cuurentId");  
                $stmt->execute(array(':cuurentId'=>$_POST['Data']));
        	    $affected_rows = $stmt->rowCount();	  
        		
        		if($affected_rows > 0)	 
        		    echo 1;
        		 else
        		    echo 2; 
        		    
            }else
                 echo 3; 
                 
    		die;  
     }
     
     if($_POST['CheckDataPin'])
     {    
          
        $MPin  = ($_POST['Data']*2)+3400; 
        $stmt = $conn->prepare("SELECT AMMT,id FROM UI__PnMX WHERE MPin=:MPin and exp!=1");  
        $stmt->execute(array(':MPin'=>$MPin));
        $affected_rows = $stmt->rowCount();	  
        
        if($affected_rows > 0)	  
        {
            $Result = $stmt->fetch(PDO::FETCH_OBJ); 
            
                if($Result->AMMT==1)  
                    $data['Data'] = "50";      
                else if($Result->AMMT==2) 
                    $data['Data'] = "100";        
                else if($Result->AMMT==3) 
                    $data['Data'] = "500";       
                else if($Result->AMMT==4) 
                    $data['Data'] = "1000";         
                else if($Result->AMMT==5) 
                    $data['Data'] = "5000";      
                else if($Result->AMMT==6) 
                    $data['Data'] = "10000";     
                
                
            $_SESSION['TpIdFetch'] = $Result->id; 
            $data['Status'] = 1;
              
        } 
        else 
             $data['Status'] = 0;
		
		echo json_encode($data);
		die;    
     }     
     
     
     if($_REQUEST['refId'])
     {  
         
            $set=0;  
    		$stmt = $conn->prepare("SELECT refId FROM UI__Rgst WHERE cuurentId=:cuurentId");  
            $stmt->execute(array(':cuurentId'=>$_REQUEST['refId']));
    	    $affected_rows = $stmt->rowCount();	 
    		
    		if($affected_rows > 0)	
    			$set=1;
    		 
    		 if($set==1) 
    		     echo json_encode(TRUE);
    		 else
    			echo json_encode(FALSE);		
    		die;
     }
     
     if($_REQUEST['ph_no'])
     {    
         
            $set=0;  
    		$stmt = $conn->prepare("SELECT phm FROM UI__Rgst WHERE phm=:ph_no");  
            $stmt->execute(array(':ph_no'=>$_REQUEST['ph_no']));
    	    $affected_rows = $stmt->rowCount();	 
    		
    		if($affected_rows > 0)	
    			$set=1;
    		 
    		 if($set==0) 
    		     echo json_encode(TRUE);
    		 else
    			echo json_encode(FALSE);		
    		die;
     }
     
     
 
?>
