<?php
include('../include/auth.php');
include('../include/lskfjwfe.php');
header('Content-Type: application/json');

$id = (int)$_POST['id'];

$query = $db2->query("DELETE FROM api_locations WHERE api_locations_id = $id");

if ($query) {
  $details = mysqli_real_escape_string($db2, json_encode(['id' => $id]));
  $db2->query("INSERT INTO action_logs (action, details, user) VALUES ('delete_api_location', '$details', '$user')");
  echo json_encode(['success' => true]);
} else {
  echo json_encode(['success' => false, 'error' => mysqli_error($db2)]);
}
