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 pathadd_task.php
More file actions
66 lines (56 loc) · 2.05 KB
/
Copy pathadd_task.php
File metadata and controls
66 lines (56 loc) · 2.05 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
<?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;
}
$status = isset($_GET['status']) ? sanitize($_GET['status']) : 'todo';
$board_id = $_SESSION['current_board'];
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$title = sanitize($_POST['title']);
$description = sanitize($_POST['description']);
$status = sanitize($_POST['status']);
// Insert task
$sql = "INSERT INTO tasks (title, description, status, board_id) VALUES ('$title', '$description', '$status', $board_id)";
if ($conn->query($sql)) {
$_SESSION['success'] = "Task added successfully!";
header("Location: index.php");
exit;
} else {
$_SESSION['error'] = "Failed to add 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>Add Task - Kanban Progress Tracker</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<h1>Add New 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="add_task.php" method="post">
<div class="form-group">
<label for="title">Task Title:</label>
<input type="text" id="title" name="title" required>
</div>
<div class="form-group">
<label for="description">Description:</label>
<textarea id="description" name="description" rows="4"></textarea>
</div>
<input type="hidden" name="status" value="<?php echo $status; ?>">
<button type="submit">Add Task</button>
</form>
</div>
</body>
</html>