<?php
session_start();
if (!isset($_SESSION["login"])) {
    header("Location: login.php");
    exit;
}
require 'header.php';

$mhs = query("SELECT * FROM kontak");
?>

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Daftar Pesan</title>
</head>

<body>
    <div class="container">
        <table class="table table-striped">
            <thead>
                <tr>
                    <th scope="col">No.</th>
                    <th scope="col">Nama</th>
                    <th scope="col">Email</th>
                    <th scope="col">Subjek</th>
                    <th scope="col">Tanggal</th>
                    <th scope="col">Aksi</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <?php $i = 1 ?>
                    <?php foreach ($mhs as $row) : ?>
                        <td><?php echo $i; ?></td>
                        <td>
                            <?= $row["nama"]; ?>
                        </td>
                        <td>
                            <?= $row["email"]; ?>
                        </td>
                        <td>
                            <a href="Admin_MenampilkanPesan.php?id=<?php echo $row["id"] ?>" class="tulisan"><?= $row["subjek"]; ?></a>
                        </td>
                        <td>
                            <?= $row["tanggal"]; ?>
                        </td>
                        <td>
                            <a href="Admin_HapusPesan.php?id=<?php echo $row["id"] ?>" onclick="return confirm('yakin?');">hapus</a>
                        </td>
                </tr>
                <?php $i++; ?>
            <?php endforeach; ?>
            </tbody>
        </table>
    </div>
</body>

<?php
require 'footer.php';
?>

</html>