koerseadmin/server/addcomment.php
2015-09-14 23:33:56 +02:00

32 lines
817 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);
$idrace = $post['idrace'];
$drivenr = $post['drivenr'];
$comment = $post['comment'];
$penaltyseconds = $post['penaltyseconds'];
$addcomment= pg_prepare($dbconn, "addcomment", "insert into comment (idrace, drivenr, comment, penaltyseconds) values ($1, $2, $3, $4)");
$addcomment= pg_execute($dbconn, "addcomment", array($idrace, $drivenr, $comment, $penaltyseconds));
if($addcomment===FALSE) {
$result['ok'] = false;
$result['error'] = 'insert comment failed: '.pg_last_error($dbconn);
} else {
$result['ok'] = true;
}
//print message
$resultjson = json_encode($result);
echo $resultjson;
?>