Помогите, пожалуйста, исправить ошибку.
require_once 'getRecipes.php';
require_once 'countIngridients.php';
if($_POST['recipe']!="") {
$recipes=getRecipe();
$newRecipe = array("id" => uniqid(), "recipe" => $_POST['recipe']);
array_push($recipes, $newRecipe);
file_put_contents('../../data/recipes.txt', json_encode($recipes, true));
// header('Location: http://' . $_SERVER['HTTP_HOST'] .$_SERVER['REQUEST_URL']);
$recipes = getRecipe();
$outpup = [];
foreach ($recipes as $key=>$value) {
$value['count'] = countIngridients($value["id"]);
array_push($outpup, $value);
}
echo json_encode($outpup);
}```
Notice: Undefined index: recipe in /home/user_7/html/LabWeb7/lib/php/putRecipe.php on line 5
$newRecipe = ...;проверь наличие полей черезprint_r($_POST);– Eugene X May 23 '22 at 17:06$_POST['recipe']!=""на!empty($_POST['recipe'])илиisset($_POST['recipe']), например. – Simon May 23 '22 at 17:44if($_POST['recipe']!="") { $recipes=getRecipe(); print_r($_POST); $newRecipe = array("id" => uniqid(), "recipe" => $_POST['recipe']); array_push($recipes, $newRecipe);``` Я ведь туда принт вставил?– Veslo May 23 '22 at 17:44if(!empty($_POST['recipe'])) {– Владимир Клыков May 23 '22 at 18:06