File "delete_ci_setting.php"

Full path: /home2/santhos2/public_html/bharath-coe.firstmatrix.in.net/api/internal_marks/delete_ci_setting.php
File size: 1.41 KiB (1440 bytes)
MIME-type: text/x-php
Charset: utf-8

Download   Open   Back

<?php
require_once __DIR__ . '/../../config/config.php';
require_once __DIR__ . '/../../config/db.php';

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

try {
    $input = json_decode(file_get_contents('php://input'), true);
    
    if (!$input || !isset($input['id'])) {
        echo json_encode(['status' => 'error', 'message' => 'Setting ID is required']);
        exit;
    }
    
    $setting_id = intval($input['id']);
    
    // Check if setting exists
    $checkStmt = $pdo->prepare("SELECT setting_id FROM ci_assessment_settings WHERE setting_id = ?");
    $checkStmt->execute([$setting_id]);
    
    if (!$checkStmt->fetch()) {
        echo json_encode([
            'status' => 'error',
            'message' => 'CI assessment setting not found'
        ]);
        exit;
    }
    
    // Delete the setting
    $deleteStmt = $pdo->prepare("DELETE FROM ci_assessment_settings WHERE setting_id = ?");
    $result = $deleteStmt->execute([$setting_id]);
    
    if ($result) {
        echo json_encode([
            'status' => 'success',
            'message' => 'CI assessment setting deleted successfully'
        ]);
    } else {
        echo json_encode([
            'status' => 'error',
            'message' => 'Failed to delete CI assessment setting'
        ]);
    }
    
} catch (Exception $e) {
    echo json_encode([
        'status' => 'error',
        'message' => 'Database error: ' . $e->getMessage()
    ]);
}
?>

PHP File Manager