<?php
		header("Access-Control-Allow-Origin: *");
		header("Access-Control-Allow-Headers: access");
		header("Access-Control-Allow-Methods: GET");
		header("Access-Control-Allow-Credentials: true");
		header("Content-Type: application/json; charset=UTF-8");

		include_once '../Database.php';
		include_once 'cliente.php';

		$database = new DataBase();
		$db = $database->getConnection();
        
	    $hoy = date('Y-m-d');
		$cliente = new CLIENTE($db);
		$cliente->correo = isset($_GET['email'])?$_GET['email']:die();
		$cliente->pass = isset($_GET['password'])?$_GET['password']:die();
		try{
			$consulta="select * from acceso where correo='".$cliente->correo."' and pass=SHA('".$cliente->pass."')";
			$stmt = $cliente->select($consulta);
		$num = $stmt->rowCount();

		if($num>0){
			$row =$stmt->fetch(PDO::FETCH_ASSOC);
				extract($row);
				
				echo json_encode(array("id"=>$id));
		}
		else {
			echo json_encode(array("Error"=>"El correo o la contraseña no coinciden"));
		    
		}
		}catch(Exception $e){
		    echo json_encode(array("Error"=>$e.getMessage()));
		}