-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompletetask.php
39 lines (28 loc) · 1011 Bytes
/
completetask.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 "./config.php";
try {
$connection = new PDO($dsn, $username, $password, $options);
$id = $_GET['id'];
$sql = "SELECT isComplete FROM tasks WHERE id = :id";
$statement = $connection->prepare($sql);
$statement->bindValue(':id', $id);
$statement->execute();
$state = $statement->fetch(PDO::FETCH_ASSOC);
if ($state['isComplete'] == 'false') {
$isComplete = 'true';
} else {
$isComplete = 'false';
}
$sql = "UPDATE tasks
SET
isComplete = :isComplete
WHERE id = :id";
$statement = $connection->prepare($sql);
$statement->bindValue(':id', $id);
$statement->bindValue(':isComplete', $isComplete);
$statement->execute();
header ("location: /index.php");
} catch(PDOException $error) {
echo $sql . "<br>" . $error->getMessage();
}
?>