-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashboard.php
More file actions
43 lines (29 loc) · 798 Bytes
/
dashboard.php
File metadata and controls
43 lines (29 loc) · 798 Bytes
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
<?php
require 'config.php';
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
}
$user_id = $_SESSION['user_id'];
$sql = "SELECT * FROM tasks WHERE user_id=? ORDER BY created_at DESC";
$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $user_id);
$stmt->execute();
$result = $stmt->get_result();
?>
<link rel="stylesheet" href="style.css">
<div class="container">
<h2>Your Tasks</h2>
<form action="add_task.php" method="POST">
<input name="task" placeholder="New task" required>
<button>Add</button>
</form>
<ul>
<?php while($row = $result->fetch_assoc()): ?>
<li>
<?php echo htmlspecialchars($row['task']); ?>
<a href="delete_task.php?id=<?php echo $row['id']; ?>">Delete</a>
</li>
<?php endwhile; ?>
</ul>
<a href="logout.php">Logout</a>
</div>