<?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);

	$idchampionship = $post['idchampionship'];
	$poule = $post['poule'];
	$tier = $post['tier'];

	$addpoule= pg_prepare($dbconn, "addpoule", "insert into poule (poule, tier, idchampionship) values ($1, $2, $3)");
	$addpoule= pg_execute($dbconn, "addpoule", array($poule, $tier, $idchampionship));

	if($addpoule===FALSE) {
		$result['ok'] = false;
		$result['error'] = pg_last_error($dbconn);
	} else {
		//return data
		$result['ok'] = true;
	}

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

	echo $resultjson;
?>
