<?php
if(!isset($_SESSION)){
session_start();
}
	$out  = array();
	$Validator = array('is_success'=>false, 'data'=>array());

	date_default_timezone_set('Asia/Baghdad');

	$LogTime = date('Y-m-d H:i:s');

	if( empty($_POST['password'])){

		$error=" Please Fill Password!";
        $State=false;
        $out  = array(
							'status'  => 'false',
							'data'  => $error
							);
	}
	else
	{
			require_once "db_connect.php";

			
			$password=$_POST['password'];


			

			$password=hash('sha256',$password);
	    	$password= stripslashes($password);
	    	$password=mysqli_real_escape_string($db,$password);

			$sql = "SELECT * FROM sys_outh WHERE  outh2_password= '" . $password . "' AND is_deleted=0 ";

	    	$query = $db->query($sql);

			if (!$query) {
		        $error= "Error: " . $db->error;
		        $State=false;

		  	}else{
		        $Records = $query->fetch_assoc();

		        $LogTime = date('Y-m-d H:i:s');

						if($Records){


							
							$_SESSION['outh2'] 			= true;

					        $error						= " Login Success";
					        $State						= true;

					        // set cookies

					        $cookie_name = "outh2";
                			$cookie_value = "LV.2";
                			setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/"); // 86400 = 1 day


					       
						}
						else{
					        $error= "Password Invalid ";
					        $State=false;
						} // if records

			} // if query

		} // if empty


			$Validator['is_success'] = $State;
      		$Validator['data'] = $error;
			echo json_encode($Validator);



?>
