<?php
include_once("../config.php");

if(isset($_POST['removeAttri'])){
    $removeAttriId = $_POST['removeAttriId'];
    $removeAttriKey = $_POST['removeAttriKey'];
    $removeAttriType = $_POST['removeAttriType'];

    if($removeAttriType == "current"){
        $removeq = mysqli_query($db, "DELETE FROM contact_attributes WHERE id=$removeAttriId");
    }else if($removeAttriType == "all"){
        $removeq = mysqli_query($db, "DELETE FROM contact_attributes WHERE attri_name='$removeAttriKey'");
    }

    if($removeq){
        echo json_encode([
            "status" => 200,
            "message" => "Deleted Successfully!!"
        ]);
    }
}

if(isset($_POST['deleteContact'])){
    $contactId = $_POST['contactId'];

    $removeq = mysqli_query($db, "DELETE FROM contacts WHERE id=$contactId");

    if($removeq){
        echo json_encode([
            "status" => 200,
            "message" => "Deleted Successfully!!"
        ]);
    }
}
?>