tdphp/td5/action/new.php

25 lines
718 B
PHP
Raw Normal View History

2023-03-22 08:13:04 +01:00
<?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");
}