<?php

require_once __DIR__ . '/db_config.php';

$response = array();

if (isset($_POST["name"]) ) {
 
$name=$_POST["name"];
$pid=$_POST["id"];
$id=$_POST["milestone"];

$con = mysqli_connect(DB_SERVER, DB_USER, DB_PASSWORD,DB_DATABASE) or die(mysql_error());
$query="SELECT milestone_id FROM task_milestone WHERE project_id='$pid' and milestone_name='$name'";
if(!empty($id)){
  $query=$query." AND milestone_id!='$id'";
}

$result=mysqli_query($con,$query);
if(!empty($result) && mysqli_num_rows($result) > 0){
   $response["exists"] =true;
}else{
    $response["exists"] =false;
}
    mysqli_close($con);

}

echo json_encode($response);


?>