Repository navigation
Expand file tree
/
Copy pathedit.php
More file actions
80 lines (70 loc) · 2.29 KB
/
Copy pathedit.php
File metadata and controls
80 lines (70 loc) · 2.29 KB
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
74
75
76
77
78
79
80
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Todo Apps</title>
<link rel="stylesheet" href="./style/style.css" />
</head>
<body>
<?php
// CREATE Todo-List
try {
require_once("config/connection.php");
$id = $_GET['id'];
// print_r($_GET["id"]);
if (isset($_POST["submit"])) {
$tugas = $_POST["tugas"];
$date = $_POST["date"];
$idGet = $_POST["id"];
$queryUpdate = "UPDATE todo_list SET tugas = '" . $tugas . "', date = '" . $date . "' WHERE id = '" . $idGet . "'";
$updated = mysqli_query($conn, $queryUpdate);
if ($updated) {
header('Location: index.php');
}
}
} catch (Exception $error) {
// Jika Ada Error maka akan di handle (ditangkap) disini
echo "Error", $error->getMessage(), "\n";
}
?>
<?php
try {
$id = $_GET["id"];
$querySelect = "SELECT * FROM todo_list WHERE id = $id";
$selected = mysqli_query($conn, $querySelect);
$tugasEdit = "";
$dateEdit = "";
$data = mysqli_fetch_assoc($selected);
$tugasEdit = $data["tugas"];
$dateEdit = $data["date"];
} catch (Exception $error) {
// Jika Ada Error maka akan di handle (ditangkap) disini
echo "Error", $error->getMessage(), "\n";
}
?>
<header>
<h1>Todo List</h1>
</header>
<div class="wrapper">
<div class="container shadow" id="add-todo">
<h2 class="container-header text-center">
Tambah Yang Harus Dilakukan
</h2>
<form class="form" action="edit.php" method="POST">
<input type="hidden" name="id" value="<?= $_GET["id"]; ?>">
<div class="form-group form-title">
<label for="tugas">Masukkan Tugas Baru</label>
<input type="text" name="tugas" id="tugas" required value="<?= $tugasEdit; ?>" />
</div>
<div class=" form-group form-title">
<label for="date">Masukkan Deadline</label>
<input type="date" name="date" id="date" required value="<?= $dateEdit; ?>" />
</div>
<input type="submit" value="Save" name="submit" id="submit" class="submit-btn" />
<a href="index.php" class="edit-btn">BACK</a>
</form>
</div>
</body>
</html>