<?php

require_once __DIR__ . '/db_config.php';

$response = array();

if (isset($_POST["cname"]) ) {
 
$cname=$_POST["cname"];
$pname=$_POST["pname"];
$id=$_POST["id"];

$con = mysqli_connect(DB_SERVER, DB_USER, DB_PASSWORD,DB_DATABASE) or die(mysql_error());


$query="SELECT project_id FROM task_project WHERE p_companyname='$cname' AND project_name='$pname'";


if(!empty($id)){
  $query=$query." AND project_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);


?>