Path : /home/vishqocm/pcib.in/admin/
File Upload :
Current File : /home/vishqocm//pcib.in/admin/update_site_settings.php

<?php
session_start();
require_once 'database/db_config.php';

// Check if user has admin privileges
require_admin_privileges('login.php');

// Check if action is specified
$action = isset($_GET['action']) ? $_GET['action'] : 'disable';

$setting_value = ($action === 'enable') ? 'true' : 'false';
$message_text = ($action === 'enable') ? 'enabled' : 'disabled';

// Insert or update the show_helper_messages setting
$stmt = $conn->prepare("INSERT INTO site_settings (setting_key, setting_value) 
                        VALUES ('show_helper_messages', ?) 
                        ON DUPLICATE KEY UPDATE setting_value = ?");
$stmt->bind_param("ss", $setting_value, $setting_value);

if ($stmt->execute()) {
    // Set a success message
    $_SESSION['success_message'] = "Helper messages have been {$message_text}.";
} else {
    // Set an error message
    $_SESSION['error_message'] = "Failed to update helper messages: " . $conn->error;
}

// Redirect back to the admin dashboard
header('Location: index.php');
exit;
?>