<?php
session_start();
$host = 'localhost';
$user = 'ahmeuesz_dino';
$pwd  = 'X39IW2ho3^5h6d_5';
$db   = 'ahmeuesz_myapp';

$conn = mysqli_connect($host, $user, $pwd, $db);

$sql = "SELECT * FROM namaz_table";
$result = mysqli_query($conn, $sql);
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Namaz Records</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <div class="container">
        <h1>Namaz Attendance Records</h1>
        <?php
        if (isset($_GET['msg'])) {
            if ($_GET['msg'] == "success") {
                echo '<p class="success-msg">Data successfully inserted!</p>';
            } else {
                echo '<p class="error-msg">Failed to insert data.</p>';
            }
        }
        ?>
        <table>
            <tr>
                <th>DATE</th>
                <th>NAME</th>
                <th>FAJAR</th>
                <th>ZUHAR</th>
                <th>ASAR</th>
                <th>MGHRIB</th>
                <th>ESHA</th>
            </tr>
            <?php while ($row = mysqli_fetch_assoc($result)) : ?>
                <tr>
                    <td><?= $row['date'] ?></td>
                    <td><?= $row['name'] ?></td>
                    <td><?= $row['fajar'] ?></td>
                    <td><?= $row['zuhar'] ?></td>
                    <td><?= $row['asar'] ?></td>
                    <td><?= $row['mghrib'] ?></td>
                    <td><?= $row['esha'] ?></td>
                </tr>
            <?php endwhile; ?>
        </table>
       <div class="button-group">
    <a class="back-btn" href="form.html">Submit Another</a>
    <a href="logout.php" class="logout-btn">Logout</a>
</div>
</div> 

</body>
</html>
