-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashboard.php
More file actions
160 lines (139 loc) · 4.07 KB
/
dashboard.php
File metadata and controls
160 lines (139 loc) · 4.07 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<?php
session_start();
include 'db.php';
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
exit();
}
$user_id = $_SESSION['user_id'];
// Handle new task submission
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['task'])) {
$task = $_POST['task'];
$stmt = $pdo->prepare("INSERT INTO tasks (user_id, task, status) VALUES (?, ?, 'pending')");
$stmt->execute([$user_id, $task]);
}
// Fetch all tasks for the logged-in user
$tasks = $pdo->prepare("SELECT * FROM tasks WHERE user_id = ? ORDER BY id DESC");
$tasks->execute([$user_id]);
$tasks = $tasks->fetchAll();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Task Management Dashboard</title>
<link rel="stylesheet" href="style.css">
<style>
body {
font-family: Arial, sans-serif;
background: linear-gradient(to right, #6a11cb, #2575fc);
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
flex-direction: column;
}
.container {
background-color: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
width: 400px;
text-align: center;
}
h2 {
color: #333;
}
.form-group {
margin-bottom: 15px;
}
input[type="text"] {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
button {
width: 100%;
padding: 10px;
background-color: #28a745;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
button:hover {
background-color: #218838;
}
h3 {
margin-top: 20px;
color: #333;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px;
border-bottom: 1px solid #ccc;
}
a {
color: #007bff;
text-decoration: none;
margin-left: 10px;
}
a:hover {
text-decoration: underline;
}
.completed {
text-decoration: line-through;
color: gray;
}
.logout {
margin-top: 20px;
display: block;
color: #007bff;
text-decoration: none;
}
.logout:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div class="container">
<h2>Task Management Dashboard</h2>
<!-- Form to Add New Task -->
<form method="POST">
<div class="form-group">
<input type="text" name="task" placeholder="New Task" required>
</div>
<button type="submit">Add Task</button>
</form>
<!-- Display User Tasks -->
<h3>Your Tasks</h3>
<ul>
<?php foreach ($tasks as $task): ?>
<li class="<?php echo $task['status'] === 'done' ? 'completed' : ''; ?>">
<?php echo htmlspecialchars($task['task']); ?>
<div>
<a href="update_task.php?id=<?php echo $task['id']; ?>">Edit</a>
<?php if ($task['status'] !== 'done'): ?>
<a href="complete_task.php?id=<?php echo $task['id']; ?>">Complete</a>
<?php endif; ?>
<a href="delete_task.php?id=<?php echo $task['id']; ?>">Delete</a>
</div>
</li>
<?php endforeach; ?>
</ul>
<!-- Logout -->
<a class="logout" href="logout.php">Logout</a>
</div>
</body>
</html>