<?php 
include_once 'db_functions.php'; 
$db = new DB_Functions(); 
$json = $_POST["docJSON"];
if (get_magic_quotes_gpc()){ 
	$json = stripslashes($json); 
}
//Decode JSON into an Array 
$data = json_decode($json); 
//Util arrays to create response JSON 
$a=array();
$b=array();
for($i=0; $i<count($data) ; $i++) {
	//Store User into MySQL DB 
	$res = $db-> uploadDoc($data[$i]->userid,$data[$i]->doc_name,$data[$i]->filename,$data[$i]->doc_file);
	$respons = explode("~",$res);
	if($respons[0]=="success"){
		$b["success"] = $respons[1];
	}else{
		$b["error"] = $respons[1];
	}
	
	//Based on inserttion, create JSON response     
	array_push($a,$b);
}
echo json_encode($a); 
?>