<?php
require "auth.php";
require_once "../config/db.php";
$stmt = $pdo->query("SELECT * FROM messages ORDER BY id DESC");
?>
<!DOCTYPE html>
<html lang="ar">
<head>
    <meta charset="UTF-8"><title>رسائل التواصل</title>
</head>
<body>
    <h2>رسائل التواصل</h2>
    <table border="1" cellpadding="6">
        <tr>
            <th>الاسم</th>
            <th>البريد</th>
            <th>الجوال</th>
            <th>الرسالة</th>
            <th>تاريخ الإرسال</th>
        </tr>
        <?php foreach($stmt as $msg): ?>
        <tr>
            <td><?= htmlspecialchars($msg['name']) ?></td>
            <td><?= htmlspecialchars($msg['email']) ?></td>
            <td><?= htmlspecialchars($msg['phone']) ?></td>
            <td><?= htmlspecialchars($msg['message']) ?></td>
            <td><?= htmlspecialchars($msg['created_at']) ?></td>
        </tr>
        <?php endforeach; ?>
    </table>
</body>
</html>
