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

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

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

$query = "UPDATE manufacturer SET 
            address = '" .$postData->address. "', 
            postcode = '" .$postData->postcode. "', 
            town = '" .$postData->town. "', 
            state = '" .$postData->state. "', 
            telephone = '" .$postData->telephone. "', 
            fax = '" .$postData->fax. "', 
            url = '" .$postData->url. "', 
            officer = '" .$postData->officer. "', 
            phone = '" .$postData->phone. "', 
            email = '" .$postData->email. "', 
            type = '" .$postData->type. "' 
            WHERE id = '" .$postData->id. "' ";

if ($mysqli->query($query) === true) {
    echo "Success: Record updated. [".$query."]";
    http_response_code(200);
} else {
    echo "Error: Process failed - " . $mysqli->error;
    http_response_code(401);
}

$mysqli->close();

?>