<?php
require_once($_SERVER['DOCUMENT_ROOT'] . '/sys/db.php');

foreach ($_POST as $paramName => $paramValue) {
  if ($paramName == "name")
    $name = $paramValue;
}

$result= [0, "Ok"];

$dal = new DAL();

$sql = "SELECT id FROM project " .
       "WHERE name = '$name' LIMIT 1";
$result = $dal->query($sql);

if (null != $result) {
  $result = [1, "Duplicate: $name"];
}

echo json_encode($result);

?>

