/
home
/
u839856410
/
domains
/
frajuuconnect.online
/
public_html
/
Upload File
HOME
<?php session_start(); include 'db_connection.php'; if (!isset($_SESSION['agent_id'])) { header("Location: login.php"); exit; } $agent_id = intval($_SESSION['agent_id']); $sql = " SELECT m.*, COALESCE( (SELECT title FROM houses_for_sale WHERE id = m.property_id), (SELECT title FROM houses_for_rent WHERE id = m.property_id), (SELECT name FROM rooms_for_rent WHERE id = m.property_id), (SELECT title FROM plots_for_sale WHERE id = m.property_id) ) AS property_title FROM messages m WHERE m.agent_id = ? ORDER BY m.created_at DESC "; $stmt = $conn->prepare($sql); $stmt->bind_param("i",$agent_id); $stmt->execute(); $res = $stmt->get_result(); ?> <!doctype html> <html> <head><meta charset="utf-8"><title>Messages</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"></head> <body> <div class="container my-5"> <div class="d-flex justify-content-end mb-3"> <a href="index.php" class="btn btn-primary btn-sm">Back to Dashboard</a> </div> <h2 class="mb-4 text-center">Messages (<?php echo htmlspecialchars($_SESSION['agent_name'] ?? 'Agent'); ?>)</h2> <?php if ($res->num_rows > 0): ?> <div class="row g-4"> <?php while($r = $res->fetch_assoc()): ?> <div class="col-md-6"> <div class="card shadow-sm h-100"> <div class="card-header bg-primary text-white"> <strong>From:</strong> <?php echo htmlspecialchars($r['name']); ?> </div> <div class="card-body"> <p><strong>Email:</strong> <?php echo htmlspecialchars($r['email']); ?></p> <p><strong>Phone:</strong> <?php echo htmlspecialchars($r['phone']); ?></p> <p><strong>Property:</strong> <?php echo htmlspecialchars(substr($r['property_title'] ?? 'N/A', 0, 50)); ?> <?php echo strlen($r['property_title'] ?? '') > 50 ? '...' : ''; ?> </p> <p><strong>Message:</strong> <?php echo nl2br(htmlspecialchars($r['message'])); ?></p> </div> <div class="card-footer text-muted text-end"> <?php echo date("d M Y, H:i", strtotime($r['created_at'])); ?> </div> </div> </div> <?php endwhile; ?> </div> <?php else: ?> <p class="alert alert-info text-center">No messages yet.</p> <?php endif; ?> </div> </body> </html>