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