-
Notifications
You must be signed in to change notification settings - Fork 0
/
performedit.php
41 lines (33 loc) · 1.1 KB
/
performedit.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
<?php
require "./config.php";
require "./common.php";
try {
$connection = new PDO($dsn, $username, $password, $options);
$task =[
"id" => escape($_POST['id']),
"summary" => escape($_POST['summary']),
"details" => escape($_POST['details']),
"priority" => escape($_POST['priority']),
"isComplete" => escape($_POST['isComplete'])
];
if ($_POST['dueDate']) {
$task += ["dueDate" => escape($_POST['dueDate'])];
} else {
$task += ["dueDate" => NULL];
}
$sql = "UPDATE tasks
SET
summary = :summary,
details = :details,
priority = :priority,
dueDate = :dueDate,
isComplete = :isComplete
WHERE id = :id";
$statement = $connection->prepare($sql);
$statement->execute($task);
header ("location: /index.php");
}
catch(PDOException $error) {
echo $sql . "<br>" . $error->getMessage();
}
?>