Update updateArticle-controller.php

This commit is contained in:
2026-06-01 09:24:51 +02:00
parent d8c350c20f
commit 560f53cfb6
+6 -3
View File
@@ -5,14 +5,17 @@ require_once '../model/ArticleManager.php';
require_once '../model/Article.php'; require_once '../model/Article.php';
if ($_SERVER["REQUEST_METHOD"] === "POST") { if ($_SERVER["REQUEST_METHOD"] === "POST") {
try {
$id = $_GET["id"];
} catch (Exception $e){
$_SESSION["message"] = "missing_id";
}
if (!isset($_POST["title"]) ||!isset($_POST["content"]) || !isset($_POST["category"])){ if (!isset($_POST["title"]) ||!isset($_POST["content"]) || !isset($_POST["category"])){
$_SESSION["message"] = "missing_parameters"; $_SESSION["message"] = "missing_parameters";
header("location: ../../index.php?pfad=updateArticle"); header("location: ../../index.php?pfad=updateArticle");
exit();
} elseif(!isset($id)) { } elseif(!isset($id)) {
$_SESSION["message"] = "missing_id"; $_SESSION["message"] = "missing_id";
header("location: ../../index.php?pfad=updateArticle"); header("location: ../../index.php?pfad=updateArticle");
exit();
}else{ }else{
$newTitle = $_POST["title"]; $newTitle = $_POST["title"];
@@ -35,9 +38,9 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
$_SESSION["message"] = "article_updated"; $_SESSION["message"] = "article_updated";
// Weiterleitung zur Homepage // Weiterleitung zur Homepage
header("location: ../../index.php"); header("location: ../../index.php");
exit();
} }
exit();
} }
?> ?>