src/App/Controllers/products.php | ●●●●● patch | view | raw | blame | history | |
views/Products/delete.php | ●●●●● patch | view | raw | blame | history |
src/App/Controllers/products.php
@@ -116,4 +116,13 @@ "product" => $product ]); } public function destroy(string $id) { $product = $this->getProduct($id); $this->model->delete($id); header("Location: /products/index"); exit; } } views/Products/delete.php
@@ -1,7 +1,7 @@ <body> <h1>Delete Product</h1> <form method="post" action="/products/<?= $product["id"]?>/delete"> <form method="post" action="/products/<?= $product["id"]?>/destroy"> <p>Delete this product?</p> <button>Yes</button> </form>