-
Notifications
You must be signed in to change notification settings - Fork 0
/
edittask.php
73 lines (60 loc) · 2.94 KB
/
edittask.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
if (isset($_POST['submit']) && $statement) {
header('Location: /index.php');
}
require "./config.php";
require "./common.php";
if (isset($_GET['id'])) {
try {
$connection = new PDO($dsn, $username, $password, $options);
$id = $_GET['id'];
$sql = "SELECT * FROM tasks WHERE id = :id";
$statement = $connection->prepare($sql);
$statement->bindValue(':id', $id);
$statement->execute();
$task = $statement->fetch(PDO::FETCH_ASSOC);
} catch(PDOException $error) {
echo $sql . "<br>" . $error->getMessage();
}
}
?>
<?php require("./templates/header.php"); ?>
<div class="container">
<?php require("./templates/nav.php"); ?>
<div class="card" style="width: 50%">
<form method="post" action="performedit.php" style="padding: 20px">
<div class="form-group">
<label for="summary" class="text-primary">Summary</label>
<input class="form-control" id="summary" name="summary" value="<?php echo $task["summary"]; ?>">
<label for="details" class="text-primary">Details</label>
<textarea rows="3" class="form-control" id="details" name="details"><?php echo $task["details"]; ?></textarea>
<label for="priority" class="text-primary">Priority</label>
<select class="form-control" id="priority" name="priority">
<?php
switch($task["priority"]) {
case 'Normal': ?>
<option>Low</option>
<option selected>Normal</option>
<option>High</option> <?php
break;
case 'High': ?>
<option>Low</option>
<option>Normal</option>
<option selected>High</option> <?php
break;
case 'Low': ?>
<option selected>Low</option>
<option>Normal</option>
<option>High</option> <?php
break;
} ?>
</select>
<input id="isComplete" name="isComplete" type="hidden" value="<?php echo $task["isComplete"]; ?>">
<input id="id" name="id" type="hidden" value="<?php echo $task["id"]; ?>">
<label for="duedate" class="text-primary">Due Date:</label>
<input type="date" class="form-control" id="duedate" name="dueDate" value="<?php echo date('Y-m-j',strtotime($task["dueDate"])); ?>">
</div>
<input type="submit" name="submit" class="btn btn-primary" value="Save Task">
</form>
</div>
</div> <!-- container -->