<?php

include "start.php";


$main_array = array();



$query_get="select * from t_".$key_table_prefix."_user_device
	    where dusr_name ='".$_REQUEST["u"]."'
	    and dusr_password ='".$_REQUEST["p"]."'
		";


$result_get = mysqli_query($dbconn, $query_get) or die("Error".mysqli_error($dbconn));
if($line_get = mysqli_fetch_array($result_get,MYSQLI_ASSOC))
{

	$this_session_id = rand(10000000000000000,90000000000000000);
	

	$query_update="update t_".$key_table_prefix."_user_device
			set dusr_session_id = '".$this_session_id."'
		    where dusr_name ='".$_REQUEST["u"]."'
		    and dusr_password ='".$_REQUEST["p"]."'
			";

	$result_update = mysqli_query($dbconn, $query_update) or die("Error".mysqli_error($dbconn));
	

	
	
	
	     $this_data = array(
			  "status" => "YES",
			  "usr_id" => "".$line_get["dusr_id"]."",
			  "session" => "".$this_session_id."",
			  "message" => "Active"
	     );

	    array_push($main_array, $this_data);


}
else {

    	$this_data = array(
		  "status" => "NO",
		  "usr_id" => "",
			
		  "session" => "",
		  "message" => "Invalid Login Information"
   	);

   array_push($main_array, $this_data);
}



$content_array["login"] = $main_array;




$json = json_encode($content_array);

echo $json;






?>
