-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathperformadd.php
34 lines (27 loc) · 1016 Bytes
/
performadd.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
<?php
require "../configs/config.php";
require "./common.php";
try {
$connection = new PDO($dsn, $username, $password, $options);
$new_task = array(
"summary" => escape($_POST['summary']),
"details" => escape($_POST['details']),
"priority" => escape($_POST['priority']),
"isComplete" => escape($_POST['isComplete'])
);
if ($_POST['dueDate']) {
$new_task+= ["dueDate" => escape($_POST['dueDate'])];
}
$sql = sprintf(
"INSERT INTO %s (%s) values (%s)",
"tasks",
implode(", ", array_keys($new_task)),
":" . implode(", :", array_keys($new_task)));
$statement = $connection->prepare($sql);
$statement->execute($new_task);
header ("location: /index.php");
}
catch(PDOException $error) {
echo $sql . "<br>" . $error->getMessage();
}
?>