diff --git a/action.php b/action.php new file mode 100644 index 0000000..142cb3a --- /dev/null +++ b/action.php @@ -0,0 +1,35 @@ +prepare($insert); + $stmt->bindParam(":NAME", $_POST["name"]); + $stmt->execute(); + + DB::closeConnection($db); + } + case "rem": { + $db = DB::openConnection(); + + $insert = "DELETE FROM users WHERE ID = :ID"; + + $stmt = $db->prepare($insert); + $stmt->bindParam(":ID", $_POST["ID"]); + $stmt->execute(); + + DB::closeConnection($db); + } + default: + break; +} + +Headers::redirect("."); diff --git a/headers.php b/headers.php index 7a7e731..528c8f4 100644 --- a/headers.php +++ b/headers.php @@ -3,6 +3,19 @@ class Headers { static function json() { + header('Content-Type: text/html; charset=utf-8'); header("Content-Type: text/json"); } + + static function html() + { + header('Content-Type: text/html; charset=utf-8'); + } + + static function redirect(string $newUrl, bool $permanent = FALSE) + { + header('Location: ' . $newUrl, true, $permanent ? 301 : 302); + + exit(); + } } diff --git a/index.css b/index.css new file mode 100644 index 0000000..4b26c5d --- /dev/null +++ b/index.css @@ -0,0 +1,56 @@ +*, ::after, ::before { + box-sizing: border-box; +} + +body { + margin: 0; + font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"; + font-size: 1rem; + font-weight: 400; + line-height: 1.5; + color: #212529; + text-align: left; + background-color: #fff; +} + +.col { + display: flex; + flex-direction: column; + gap: 5px; + height: 100vh; +} + +.list { + margin: 10px; + overflow: scroll; + display: flex; + flex-direction: column; + gap: 5px; + flex-grow: 1; +} + +.list .item { + display: flex; + justify-content: space-between; + gap: 5px; +} + +.list .item .marker { + width: 40px; + text-align: end; +} + +.list .item .content { + width: 100%; + text-align: start; +} + +.add { + margin: 10px; + display: flex; + gap: 5px; +} + +.add input[name="name"] { + width: 100% +} \ No newline at end of file diff --git a/index.php b/index.php index 738bd58..72d9c86 100644 --- a/index.php +++ b/index.php @@ -1,17 +1,55 @@ - + -$db = DB::openConnection(); +
+ -$query = "SELECT * FROM users"; + + -$stmt = $db->prepare($query); -$stmt->execute(); -$result = $stmt->fetch(PDO::FETCH_ASSOC); +