View sourcecode

The following files exists in this folder. Click to view.

dashboard.php

58 lines UTF-8 Unix (LF)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
require "config.php";
if (!isset(
$_SESSION['user_id'])) { header("Location: login.php"); exit; }

$stmt $db->prepare("SELECT * FROM accounts WHERE user_id = ?");
$stmt->execute([$_SESSION['user_id']]);
$accounts $stmt->fetchAll(PDO::FETCH_ASSOC);
?>
<!DOCTYPE html>
<html lang="sv">
<head>
    <meta charset="UTF-8">
    <title>Mina konton</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="bg-light">

<div class="container py-5">
    <div class="row justify-content-center">
        <div class="col-md-7">

            <div class="card shadow-sm">
                <div class="card-header bg-primary text-white text-center">
                    <h3>Mina konton</h3>
                </div>

                <div class="card-body">

                    <div class="d-flex justify-content-between mb-3">
                        <a href="create_account.php" class="btn btn-success">Skapa konto</a>
                        <a href="logout.php" class="btn btn-outline-danger">Logga ut</a>
                    </div>

                    <?php if (empty($accounts)): ?>
                        <p class="text-center text-muted">Du har inga konton ännu.</p>
                    <?php else: ?>
                        <ul class="list-group">
                            <?php foreach ($accounts as $acc): ?>
                                <li class="list-group-item d-flex justify-content-between">
                                    <strong><?= htmlspecialchars($acc['account_name']) ?></strong>
                                    <a href="account.php?id=<?= $acc['id'?>" class="btn btn-sm btn-primary">
                                        Öppna (<?= $acc['balance'?> kr)
                                    </a>
                                </li>
                            <?php endforeach; ?>
                        </ul>
                    <?php endif; ?>

                </div>
            </div>

        </div>
    </div>
</div>

</body>
</html>