<?php

if (isset($_POST['numdoc']) && $_POST['numdoc'] != ""){
	$doc=$_POST['numdoc'];
	
	include_once('../php_conexion.php');
	header('Content-type: application/json; charset=utf-8');

		$query = mysqli_query($conexion, "SELECT * FROM principal_paciente WHERE numdoc=".$doc." ORDER BY id DESC LIMIT 1") or die ("ERROR EN QUERY".mysql_error());;
		$result=array();
		$count = mysqli_num_rows($query);
		
		if($count>0){
			$result["succes"]=1;
			$result = mysqli_fetch_array($query);
		}else{
			$result["error"]=4;
			$result["error_msg"]="Usuario no registrado";
		}
		
		echo json_encode($result);
		mysqli_close($conexion);
}else{
	echo "Acceso denegado";
}/*
include_once('../php_conexion.php');
//	header('Content-type: application/json; charset=utf-8');

		$query = mysql_query("SELECT * FROM principal_paciente WHERE numdoc=45841369") or die ("ERROR EN QUERY".mysql_error());
		$result=array();
		$count = mysql_num_rows($query);
		$i=0;
		while($row=mysql_fetch_array($query)){
			echo $row['numdoc']."<br>";
			$i++;
		}
		//if($count>0){
		//	$result["succes"]=1;
		//	$result = mysql_fetch_array($query) or die (mysql_error());
		//}else{
		//	$result["error"]=4;
		//	$result["error_msg"]="Usuario no registrado";
		//}

		
		echo json_encode($result);
		mysql_close($conexion);
*/		

?>