fellybikush's picture
Upload 99 files
0dff816 verified
raw
history blame
1.06 kB
<?php
// get-agent.php
session_start();
if (!isset($_SESSION['logged_in']) || $_SESSION['logged_in'] !== true) {
header('HTTP/1.1 401 Unauthorized');
echo json_encode(['error' => 'Unauthorized']);
exit;
}
// Include agent functions
require_once 'agent-functions.php';
if (isset($_GET['id'])) {
$agentId = intval($_GET['id']);
$agent = getAgentDetails($agentId);
if ($agent) {
header('Content-Type: application/json');
echo json_encode($agent);
} else {
// Return dummy data for testing
$dummyAgent = [
'id' => $agentId,
'full_name' => 'Test Agent ' . $agentId,
'phone' => '+254 7XX XXX XXX',
'location' => 'Nairobi',
'applied_at' => date('Y-m-d H:i:s'),
'id_front' => '#',
'id_back' => '#'
];
header('Content-Type: application/json');
echo json_encode($dummyAgent);
}
} else {
header('HTTP/1.1 400 Bad Request');
echo json_encode(['error' => 'Agent ID required']);
}
?>