This repository was archived by the owner on Jul 24, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedit_task.php
More file actions
88 lines (75 loc) · 2.88 KB
/
Copy pathedit_task.php
File metadata and controls
88 lines (75 loc) · 2.88 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
<?php
require_once 'config.php';
// Check if user is logged in
if (!isset($_SESSION['user_id']) || !isset($_SESSION['current_board'])) {
header("Location: index.php");
exit;
}
if (!isset($_GET['id'])) {
header("Location: index.php");
exit;
}
$task_id = (int)$_GET['id'];
$board_id = $_SESSION['current_board'];
// Get task
$result = $conn->query("SELECT * FROM tasks WHERE id = $task_id AND board_id = $board_id");
if ($result->num_rows !== 1) {
$_SESSION['error'] = "Task not found";
header("Location: index.php");
exit;
}
$task = $result->fetch_assoc();
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$title = sanitize($_POST['title']);
$description = sanitize($_POST['description']);
$status = sanitize($_POST['status']);
// Update task
$sql = "UPDATE tasks SET title = '$title', description = '$description', status = '$status' WHERE id = $task_id";
if ($conn->query($sql)) {
$_SESSION['success'] = "Task updated successfully!";
header("Location: index.php");
exit;
} else {
$_SESSION['error'] = "Failed to update task: " . $conn->error;
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Edit Task - Kanban Progress Tracker</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<h1>Edit Task</h1>
<a href="index.php" class="btn">Back to Board</a>
</header>
<div class="form-container">
<?php if (isset($_SESSION['error'])): ?>
<div class="error"><?php echo $_SESSION['error']; unset($_SESSION['error']); ?></div>
<?php endif; ?>
<form action="edit_task.php?id=<?php echo $task_id; ?>" method="post">
<div class="form-group">
<label for="title">Task Title:</label>
<input type="text" id="title" name="title" value="<?php echo $task['title']; ?>" required>
</div>
<div class="form-group">
<label for="description">Description:</label>
<textarea id="description" name="description" rows="4"><?php echo $task['description']; ?></textarea>
</div>
<div class="form-group">
<label for="status">Status:</label>
<select id="status" name="status">
<option value="todo" <?php if ($task['status'] == 'todo') echo 'selected'; ?>>To Do</option>
<option value="in_progress" <?php if ($task['status'] == 'in_progress') echo 'selected'; ?>>In Progress</option>
<option value="done" <?php if ($task['status'] == 'done') echo 'selected'; ?>>Done</option>
</select>
</div>
<button type="submit">Update Task</button>
</form>
</div>
</body>
</html>