<?php session_start(); if ($_SESSION["user"]["role"] != "admin") { header("Location: index.php"); } if (isset($_POST["valide"])) { $newperso = array( "name" => $_POST["nom"], "birthDate" => $_POST["bdate"], "deathDate" => $_POST["ddate"], "image" => $_POST["imgurl"], "description" => $_POST["description"] ); $actuel = file_get_contents('../personnages.json'); $listeTemp = json_decode($actuel, true); print_r($listeTemp["historicalFigures"]); array_push($listeTemp["historicalFigures"], $newperso); $donneesJson = json_encode($listeTemp); file_put_contents('../personnages.json', $donneesJson); header("Location: ../persos.php"); }