<?php
// Enable error display
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

echo "Starting test...<br>";

session_start();
echo "Session started<br>";

include_once('../include/session.php');
echo "Session.php loaded<br>";

require_once '../include/class.user.php';
echo "class.user.php loaded<br>";

// Test database connection
require_once '../include/dbconfig.php';
echo "Database connected<br>";

// Test query
$reg_user = new USER();
echo "USER class instantiated<br>";

if (isset($_SESSION['uname'])) {
    echo "Session uname: " . $_SESSION['uname'] . "<br>";
    
    $stmt = $reg_user->runQuery("SELECT * FROM account WHERE uname=:uname");
    $stmt->execute(array(":uname" => $_SESSION['uname']));
    $row = $stmt->fetch(PDO::FETCH_ASSOC);
    
    echo "Query executed successfully<br>";
    echo "Account data fetched<br>";
    
    // Check if ibf and erm exist
    if (isset($row['ibf'])) {
        echo "IBF value: " . $row['ibf'] . "<br>";
    } else {
        echo "IBF column not in result<br>";
    }
    
    if (isset($row['erm'])) {
        echo "ERM value: " . $row['erm'] . "<br>";
    } else {
        echo "ERM column not in result<br>";
    }
    
    echo "<br>All tests passed! The issue is elsewhere.";
} else {
    echo "No session found. Please login first.";
}
?>
