csrtechnew.ohctech.in/delete_govemnet_participation.php
2025-04-14 13:28:09 +05:30

43 lines
1.5 KiB
PHP

<?php
include('includes/config/config.php');
include('includes/functions.php');
include('log_entry.php');
error_log("Start Printing Request Attributes");
$requestStr = "";
foreach ($_REQUEST as $key => $value) {
$requestStr .= $key . " : " . $value . "\n";
error_log($key . " : " . $value);
}
error_log("End Printing Request Attributes");
// Log the request
save_log($requestStr, 'delete village', 'DELETE', 'delete_village.php');
// Check if village_id is provided in the request
if (!empty($_REQUEST['village_id'])) {
// Escape the village_id to prevent SQL injection
$villageId = mysqli_real_escape_string($conn, $_REQUEST['village_id']);
// Construct the delete query
$query = "DELETE FROM govemnet_participation WHERE id = '$villageId'";
// Log the query for debugging
error_log('role_code_delete: ' . $query);
// Execute the query and handle errors
if (!$result = mysqli_query($conn, $query)) {
// If query execution fails, log the error and return FAILURE response
error_log('Database error: ' . mysqli_error($conn));
echo json_encode(["status" => "FAILURE", "error" => mysqli_error($conn)]);
exit;
} else {
// If query execution succeeds, return SUCCESS response
echo json_encode(["status" => "SUCCESS"]);
}
} else {
// If village_id is not provided, return an error response
echo json_encode(["status" => "FAILURE", "message" => "village_id is required."]);
}
?>