<?php include '../../settings.php'; include '../../inc/login_functions.php'; include '../../inc/helper.php'; include 'functions.php'; $logedIn = access($mysqli); $result = saveArticle($mysqli, $_SESSION['userId']); include '../../inc/header.php'; include "../../inc/topNavbar.php"; ?> <section id="main-container"> <?php include "../../inc/leftNavbar.php"; ?> <!--Page main section start--> <section id="min-wrapper"> <div id="main-content"> <div class="container-fluid"> <div class="row"> <div class="col-md-12"> <?php if ($result === 1) { echo '<div class="alert alert-danger">'; echo "Du hast nicht alle Felder ausgefüllt."; echo '</div>';
} if (isset($_SESSION['id_user'])) { if (isset($_POST['submit'])) { // Récupère les données de l'article à sauvegarder $articleToEdit['id_article'] = $_POST['id_article']; $articleToEdit['title_article'] = $_POST['title_article']; $articleToEdit['content_article'] = $_POST['content_article']; $articleToEdit['id_user'] = $_SESSION['id_user']; if (isset($articleToEdit['date_article'])) { $articleDate = array_reverse(array_values($articleToEdit['date_article'])); } // sauvegarde d'un article $errors = validArticle($articleToEdit); if (empty($errors)) { $articleToEdit['date_article'] = implode("-", $articleDate); saveArticle($articleToEdit); header('Location: index.php'); exit; } } else { // Récupère un article à modifier if ($id && getArticles($id)[0]['id_user'] == $_SESSION['id_user']) { if ($edit == 'remove') { deleteArticle($_GET['id']); header('Location: index.php'); exit; } else { $articleToEdit = getArticles($id)[0]; $comments = getCommentsByArticle($id); if (!is_array($articleToEdit['date_article'])) { $articleDate = explode('-', $articleToEdit['date_article']);