-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_task.php
More file actions
90 lines (80 loc) · 2.76 KB
/
add_task.php
File metadata and controls
90 lines (80 loc) · 2.76 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
<?php
session_start();
// Redirect to login if not logged in
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
exit;
}
include 'db.php';
if (isset($_POST['add_task'])) {
$title = $_POST['title'];
$description = $_POST['description'];
$deadline = $_POST['deadline'];
$status = $_POST['status']; // Added status field
$user_id = $_SESSION['user_id'];
try {
$sql = "INSERT INTO tasks (title, description, deadline, status, user_id) VALUES (:title, :description, :deadline, :status, :user_id)";
$stmt = $conn->prepare($sql);
$stmt->bindParam(':title', $title);
$stmt->bindParam(':description', $description);
$stmt->bindParam(':deadline', $deadline);
$stmt->bindParam(':status', $status); // Bind status field
$stmt->bindParam(':user_id', $user_id);
$stmt->execute();
header("Location: dashboard.php"); // Redirect back to the dashboard after adding the task
} catch (PDOException $e) {
echo "Error adding task: " . $e->getMessage();
exit;
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Add New Task</title>
<link rel="stylesheet" href="css/style.css">
</head>
<style>
body {
background-image: url('bg1.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
background-size: 100% 100%;
}
</style>
<body>
<!-- Navigation Bar -->
<nav>
<div class="nav-container">
<div class="logo">TaskManager</div>
<ul>
<!-- <li><a href="home.php">Home</a></li> -->
<li><a href="dashboard.php">Dashboard</a></li>
</ul>
<a href="logout.php" class="logout">Logout</a>
</div>
</nav>
<h4><u>Add New Task</u></h4>
<form action="add_task.php" method="POST" onsubmit="return validateTaskForm(event)">
<label for="title">Title:</label>
<input type="text" id="title" name="title" required>
<br><br>
<label for="description">Description:</label>
<textarea id="description" name="description" required></textarea>
<br><br>
<label for="deadline">Deadline:</label>
<input type="date" id="deadline" name="deadline" required>
<br><br>
<label for="status">Status:</label>
<select id="status" name="status" required>
<option value="To Do">To Do</option>
<option value="In Progress">In Progress</option>
<option value="Completed">Completed</option>
</select>
<br><br>
<button type="submit" name="add_task">Add Task</button>
</form>
</body>
</html>