-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathverify_task.php
50 lines (44 loc) · 1.44 KB
/
verify_task.php
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
<?php
session_start();
if(!isset($_SESSION["user"])) {
header("location: login.php");
exit();
}
ini_set('display_startup_errors', true);
error_reporting(E_ALL);
ini_set('display_errors', true);
$errors = array();
$db = mysqli_connect('emps-sql.ex.ac.uk', 'wc352', 'wc352', 'wc352', '3306');
if (isset($_POST['new_task'])) {
$username = $_SESSION["user"];
$id = $_POST['id'];
$title = htmlspecialchars($_POST['title']);
$description = htmlspecialchars($_POST['description']);
$due_date = $_POST['due_date'];
$done = False;
if (empty($errors)) {
$query = "INSERT INTO tasks (username, title, description, due_date, done) VALUES('$username', '$title', '$description', '$due_date', '$done')";
mysqli_query($db, $query);
header("location: tasks.php");
exit();
} else {
$_SESSION["errors"] = $errors;
}
}
if (isset($_POST['edit_task'])) {
$id = $_POST['id'];
$title = htmlspecialchars($_POST['title']);
$description = htmlspecialchars($_POST['description']);
$due_date = $_POST['due_date'];
$query = "UPDATE tasks SET title='$title', description='$description', due_date='$due_date' WHERE id='$id'";
mysqli_query($db, $query);
header("location: tasks.php");
exit();
}
if (isset($_POST['delete_task'])) {
$id = $_POST['id'];
$query = "DELETE FROM tasks WHERE id='$id'";
mysqli_query($db, $query);
header("location: tasks.php");
exit();
}