Sindbad~EG File Manager

Current Path : /home/copmadinaarea/thecopmadinaarea.org/attendance/admin/
Upload File :
Current File : /home/copmadinaarea/thecopmadinaarea.org/attendance/admin/test_api.php

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

// Simple test to check if API is working
echo "<h2>API Test</h2>";

if (!isLoggedIn()) {
    echo "<p style='color: red;'>Not logged in</p>";
    exit;
}

echo "<p style='color: green;'>User is logged in: " . ($_SESSION['full_name'] ?? 'Unknown') . "</p>";

$db = new Database();
$conn = $db->getConnection();

try {
    // Test basic query
    $query = "SELECT COUNT(*) as total FROM attendance_records";
    $stmt = $conn->prepare($query);
    $stmt->execute();
    $total = $stmt->fetch()['total'];
    
    echo "<p>Total attendance records: $total</p>";
    
    // Test API endpoint
    echo "<h3>Testing API Endpoint:</h3>";
    echo "<button onclick='testAPI()'>Test Load More API</button>";
    echo "<div id='result'></div>";
    
} catch (Exception $e) {
    echo "<p style='color: red;'>Database error: " . $e->getMessage() . "</p>";
}
?>

<script>
async function testAPI() {
    const resultDiv = document.getElementById('result');
    resultDiv.innerHTML = 'Loading...';
    
    try {
        const response = await fetch('api/get_attendance.php?page=1&limit=5');
        const data = await response.json();
        
        resultDiv.innerHTML = '<pre>' + JSON.stringify(data, null, 2) + '</pre>';
    } catch (error) {
        resultDiv.innerHTML = '<p style="color: red;">Error: ' + error.message + '</p>';
    }
}
</script>

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists