This repository has been archived on 2025-02-26. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
tp_twigg/tpCrudTwig/public/roles/edit.php
2024-10-25 16:49:52 +02:00

33 lines
732 B
PHP

<?php
session_start();
$SERVER_ROOT = $_SERVER['DOCUMENT_ROOT'] . "/tpCrudTwig";
require_once($SERVER_ROOT . "/src/Role.php");
require_once($SERVER_ROOT . "/src/Twig.php");
if (isset($_POST)) {
if (
isset($_POST['id']) && !empty($_POST['id'])
&& isset($_POST['name']) && !empty($_POST['name'])
) {
$id = strip_tags($_GET['id']);
$name = strip_tags($_POST['name']);
$role = GetRole($id);
$role->name = $name;
UpdateRole($role);
$_SESSION['message'] = "Rôle modifié avec succès !";
header('Location: /tpCrudTwig/public/roles/list.php');
}
}
if (isset($_GET['id']) && !empty($_GET['id'])) {
$id = strip_tags($_GET['id']);
$role = GetRole($id);
}
renderTwig("roles/edit.twig", array("role" => $role));