<?php
function logActivity($log_conn, $admin_id, $activity){

    if(!$log_conn) return;

    $ip = $_SERVER['REMOTE_ADDR'] ?? 'Unknown';

    $stmt = $log_conn->prepare("
        INSERT INTO admin_activity_logs 
        (admin_id, activity, ip_address) 
        VALUES (?, ?, ?)
    ");

    if($stmt === false){
        return; // stop silently if table error
    }

    $stmt->bind_param("iss", $admin_id, $activity, $ip);
    $stmt->execute();
    $stmt->close();
}