-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddtask.php
More file actions
40 lines (34 loc) · 1.26 KB
/
Copy pathaddtask.php
File metadata and controls
40 lines (34 loc) · 1.26 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
<?php
session_start();
include 'config.php';
$userId = $_SESSION['id'];
$username = $_SESSION['username'];
$taskName = $_POST['taskName'];
$taskStarted = $_POST['taskStarted'];
$taskDeadline = $_POST['taskDeadline'];
$taskDescription = $_POST['taskDescription'];
$group_ids = $_POST['group_ids'];
foreach ($group_ids as $groupId) {
$sql = "INSERT INTO tasks (task_title, task_started, task_deadline, description, teachertask_name,id_groupetask,status) VALUES (?, ?, ?, ?, ?,?,?)";
$stmt = $conn->prepare($sql);
$stmt->bind_param("sssssis", $taskName, $taskStarted, $taskDeadline, $taskDescription, $username,$groupId,$status);
$status = 'started';
$stmt->execute();
}
//$taskId = $conn->insert_id;
// foreach ($group_ids as $groupId) {
// $sql = "INSERT INTO task_group (task_id, group_id) VALUES (?, ?)";
// $stmt = $conn->prepare($sql);
// $stmt->bind_param("ii", $taskId, $groupId);
// $stmt->execute();
// }
// ///redirection
//redirect with session role
if ($_SESSION['role'] == 'superadmin') {
header('Location: tasks.php');
} elseif ($_SESSION['role'] == 'student') {
header('Location: tasksstudent.php');
} elseif ($_SESSION['role'] == 'teacher') {
header('Location: teachertask.php');
}
?>