forked from snyk-labs/php-goof
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tasks.php
39 lines (27 loc) · 890 Bytes
/
tasks.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
<?php
require('func.php');
if(isset($_POST['save_task'])){
$title = urlencode($_POST['title']);
if(isset($_POST['edid'])) {
$edid = $_POST['edid'];
$query = "UPDATE task SET title = '$title' WHERE id = '$edid'";
}
else $query = "INSERT INTO task(title) VALUES ('$title')";
$result = mysqli_query($conn, $query);
if(!$result){
die("Query failed");
}
$_SESSION['message'] = 'Task saved successfully';
$_SESSION['message_type'] = 'success';
} elseif (isset($_GET['delid'])) {
$id = $_GET['delid'];
$query = "DELETE FROM task WHERE id = $id";
$result = mysqli_query($conn, $query);
if(!$result){
die("Query failed");
}
$_SESSION['message'] = 'Task removed successfully';
$_SESSION['message_type'] = 'warning';
}
header('Location: index.php');
?>