<?php include 'header.php'; ?> </header> <section> <div class="row"> <div class="col-sm-6 col-sm-offset-3"> <?php if (htmlentities(addslashes(isset($_POST['id'])))) { $news = $controleur->getNewsId($_POST['id']); echo "<form method='POST' action='updateNews.php'>\n <fieldset>\n <legend>Form update news</legend>\n <input type='hidden' id='id' name='id' value='" . $_POST['id'] . "'/>\n <label class='col-sm-4' for='title'>Title: </label>\n <input class='col-sm-8' type='text' id='title' name='title' value='" . $news->getTitle() . "' maxlength='100'/>\n <label class='col-sm-4' for='abstract'>Abstract: </label>\n <textarea class='col-sm-8' id='abstract' name='abstract'>" . $news->getAbstractNews() . "</textarea>\n <label class='col-sm-4' for='content'>Content: </label>\n <textarea class='col-sm-8' id='content' name='content'>" . $news->getContent() . "</textarea>\n <input type='hidden' id='datecreated' name='datecreated' value='" . $news->getDateCreated() . "'/>\n <input class='col-sm-8 col-sm-offset-4 btn btn-primary' type='submit' name='btnupdatenews' value='UPDATE'/>\n </fieldset> </form>"; } else { if (isset($_POST['btnupdatenews'])) { $image = array(); //TEMP $controleur = new Controleur(); $news = new Article(htmlentities(addslashes($_POST['title'])), htmlentities(addslashes($_POST['abstract'])), htmlentities(addslashes($_POST['content'])), htmlentities(addslashes($_POST['datecreated'])), date("Y-m-d"), $image); $news->setId($_POST['id']); $controleur->updateNews($news); header('Location: news.php'); } else { header('Location:home.php'); } } ?> </div> </div> </section> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> </body> </html>