From b8814e5220be5edfb7d856e4067c51bbaac5129b Mon Sep 17 00:00:00 2001 From: Thomas Rubini <74205383+ThomasRubini@users.noreply.github.com> Date: Tue, 24 Jan 2023 11:37:07 +0100 Subject: [PATCH 1/2] redirect on appr creation/deletion --- Controllers/ApprController.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Controllers/ApprController.php b/Controllers/ApprController.php index 7eadc18..d3d247c 100644 --- a/Controllers/ApprController.php +++ b/Controllers/ApprController.php @@ -13,7 +13,8 @@ final class ApprController $O_apprModel = new ApprModel(); $O_apprModel->createAppr($_SESSION["ID"], $I_recipe_id, $S_comment, $I_score); - + + header("Location: ".$_SERVER['HTTP_REFERER']); } public function deleteAction(Array $A_urlParams = null, Array $A_postParams = null) @@ -35,8 +36,6 @@ final class ApprController $O_apprModel->deleteAppr($I_appr_id); - echo "Appreciation $I_appr_id supprimée avec succès"; + header("Location: ".$_SERVER['HTTP_REFERER']); } - - -} \ No newline at end of file +} From 594e59d80af8d5053824a331f5fd03e96196111c Mon Sep 17 00:00:00 2001 From: Thomas Rubini <74205383+ThomasRubini@users.noreply.github.com> Date: Tue, 24 Jan 2023 11:52:23 +0100 Subject: [PATCH 2/2] Do not disable redirections + document index.php error handling --- index.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/index.php b/index.php index edb45c5..ac4e21b 100644 --- a/index.php +++ b/index.php @@ -44,8 +44,13 @@ } if ($I_err_httpCode !== null) { - http_response_code($I_err_httpCode); + + // do not disable redirects + if(http_response_code() !== 302) { + http_response_code($I_err_httpCode); + } + // Make the user see the error in these cases if($I_err_httpCode === 500 || $I_err_httpCode === 400) { header_remove("Location"); }