<?php

require_once __DIR__ . '/db_config.php';

$response = array();

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

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


$query="SELECT cat_id FROM task_category WHERE cat_companyname='$cname' AND task_categoryname='$name'";

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


?>