Mini Shell

Direktori : /home2/aravindar/public_html/admin/ajax/
Upload File :
Current File : /home2/aravindar/public_html/admin/ajax/deletetestimonial.php

<?php
include("../config.php");
$conn = dbconnect();

date_default_timezone_set('Asia/Kolkata');
header('Content-Type: application/json');

$id = isset($_POST['news_id']) ? $_POST['news_id'] : '';

if ($id) {
    $sql = "DELETE FROM tb1_testimonial WHERE id = ?";
    $stmt = $conn->prepare($sql);

    $stmt->bind_param("i", $id);

    if ($stmt->execute()) {
        if ($stmt->affected_rows > 0) {
            $response = [
                'message' => 'Record deleted successfully',
                'status' => '200',
            ];
        } else {
            $response = [
                'status' => '500',
                'message' => 'Record not found',
            ];
        }
    } else {
        $response = [
            'status' => '500',
            'message' => 'Error executing query',
        ];
    }

    $stmt->close();
} else {
    $response = [
        'status' => '400',
        'message' => 'Invalid request, id is missing',
    ];
}

$conn->close();

echo json_encode($response);

Zerion Mini Shell 1.0