From 7c4ab54f4592f13a42aeb1839ca7531faa65aebc Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 19 Jan 2023 14:27:30 +0100 Subject: [PATCH] add: createIngredients --- index.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/index.php b/index.php index b742cb0..fda4685 100644 --- a/index.php +++ b/index.php @@ -58,4 +58,14 @@ $app->post("/login", function( array $req, Response $res) use ($db) { } }); +$app->post("/createingredients", function (array $req, Response $res) use ($db) { + $newIngredient = $req["body"]["ingredient"]; + $newCalorie = $req["body"]["calories"]; + $newWeight = $req["body"]["weight"]; + $newPrice = $req["body"]["price"]; + $db->insert("ingredienti", ["cognome" => "$newIngredient", "caloriePerCento" => "$newCalorie", "ilPeso" => "$newWeight", "prezzo" => "$newPrice"]); + + $res->send("New ingredient has been listed "); +}); + $app->start(); \ No newline at end of file