Ejemplo n.º 1
0
<?php

//Insertion d'un nouveau message
if (isset($_POST['insert'], $_POST['contenu'], $_GET['id'])) {
    $id_topic = $_GET['id'];
    $manager = new Categorie($link);
    $topic = $manager->selectById($id_topic);
    try {
        $message = $topic->create($_POST['contenu']);
    } catch (Exception $e) {
        $error = $e->getMessage();
    }
    if (empty($error)) {
        // $_SERVER
        // url du fichier index.php
        header('Location: ' . str_replace('index.php', '', $_SERVER['SCRIPT_NAME']) . 'home/' . $topic->getCategory()->getCategory() . '/' . urlencode($topic->getTitre()));
        exit;
    }
} else {
    //Récupération des infos message, topic, category
    if (isset($_GET['id'])) {
        $id = $_GET['id'];
        $manager = new Topic($link);
        $message = $manager->selectById($id);
        $topic = $message->getTopic();
        $categorie = $topic->getCategory();
        $categoryName = $topic->getCategory()->getCategory();
        $topicName = urlencode($topic->getTitre());
    }
    //Mise à jour d'un message
    if (isset($_POST['update'], $_POST['contenu'])) {
Ejemplo n.º 2
0
<?php

$manager = new UserManager($link);
$user = $manager->selectById($_SESSION['id']);
$manager = new Categorie($link);
$topic = $manager->selectById($_GET['id']);
if (isset($topic)) {
    require './views/modify-topic.phtml';
}
Ejemplo n.º 3
0
 public function getTopic()
 {
     $manager = new Categorie($this->link);
     $topic = $manager->selectById($this->id_topic);
     return $topic;
 }