<?php

include_once 'db_functions.php'; 
$db = new DB_Functions(); 
$json = $_REQUEST["usersJSON"];
if (get_magic_quotes_gpc()){ 
	$json = stripslashes($json); 
}
//Decode JSON into an Array 
$data = json_decode($json); 
print_r($data);
//Util arrays to create response JSON 
$a=array();
$b=array();

for($i=0; $i<count($data) ; $i++) {

	$retailer_code=$data[$i]->retailer_code;
    $retailer_name=$data[$i]->retailer_name;
    $create_by=$data[$i]->create_by;
    $contact_person_name=$data[$i]->contact_person_name;
    $location=$data[$i]->location;
    $contact_no=$data[$i]->contact_no;
    $entry_date=date("Y-m-d");

	//Store User into MySQL DB 
	$res = $db->contact_book($retailer_code,$retailer_name,$create_by,$contact_person_name,$location,$contact_no,$entry_date);
	//Based on inserttion, create JSON response     
 	array_push($a,$res);  
}
//Post JSON response back to Android Application 
echo json_encode($a); 
?>


