koerseadmin/server/addchampionship.php
2015-09-03 22:36:35 +02:00

28 lines
590 B
PHP

<?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);
$addchamp= pg_prepare($dbconn, "addchamp", "insert into championship (name) values ($1)");
$addchamp= pg_execute($dbconn, "addchamp", array($post['name']));
if($addchamp===FALSE) {
$result['ok'] = false;
$result['error'] = pg_last_error($dbconn);
} else {
//return data
$result['ok'] = true;
}
//print message
$resultjson = json_encode($result);
echo $resultjson;
?>