<?
header('Access-Control-Allow-Origin: *');

//var_dump(json_decode(file_get_contents("php://input")));
$postData = json_decode(file_get_contents("php://input"));

//echo 'Hello...here1' .'<br/>';
//echo 'Result:' . '<br/>';
//echo $postData->name;
//die();

//$query = "INSERT INTO reports (name, location, photo, remark1, area) VALUES ('" .$postData->nama. "', '" .$postData->lokasi. "', '" .$postData->photo. "', '" .$postData->laporan. "', '" .$postData->loc. "') ";
$query = "INSERT INTO reports (name, location, photo, photo2, photo3, photo4, remark1, area, officer) VALUES ('" .$postData->nama. "', '" .$postData->lokasi. "', '" .$postData->photo1. "', '" .$postData->photo2. "', '" .$postData->photo3. "', '" .$postData->photo4. "', '" .$postData->laporan. "', '" .$postData->loc. "', 'officer1') ";
//echo 'query = ' .$query;
//die();

//$mysqli = new mysqli("localhost", "afxtech1_myori", "myori2017", "afxtech1_myori");
include_once("db_connect.php");
if ($mysqli->connect_error) {
    die("Connection failed: " . $mysqli->connect_error);
} 

if ($mysqli->query($query) === TRUE) {
    echo "New record created successfully";
    http_response_code(200);
} else {
    echo "Error: " . $query . "<br>" . $mysqli->error;
    http_response_code(500);
}

$mysqli->close();

echo $result;

?>