<?php
	include_once("db.php");

	//make result object
	$result = array();
	$result['ok'] = false;

	//get post data
	$postdata = file_get_contents("php://input");
	$post = json_decode($postdata, true);

	$idmeasurement = $post['idmeasurement'];
	$valid = $post['valid'];

	$updatemeasurement = pg_prepare($dbconn, "updatemeasurement", "update measurement set valid = $1 where idmeasurement = $2");
	$updatemeasurement = pg_execute($dbconn, "updatemeasurement", array($valid, $idmeasurement));

	if($updatemeasurement===FALSE) {
		$result['ok'] = false;
		$result['error'] = pg_last_error($dbconn);
	} else {
		//return data
		$result['ok'] = true;
		$result['debug'] = 'update measurement '.$post['idmeasurement'];
	}

	//print message
	$resultjson =  json_encode($result);

	echo $resultjson;
?>
