$question = question($id); if ($question == null) { die("question invalide."); } $contenu = $question['contenu']; $user = userfromid($question['auteur']); $pseudo = $user['pseudo']; echo "<div class='well'>\n <p id='p'> {$pseudo}: </p><p id='m'> {$contenu}</p>"; if ($question['auteur'] == $_SESSION['userid']) { echo "<a id='c' href='back_questions_form.php?edite={$id}'>éditer</a>"; } echo "</div>"; ?> <?php echo "<h1>Liste des réponses:</h1>"; $reponses = reponses($_GET['questionid']); foreach ($reponses as $reponse) { $contenu = $reponse['contenu']; $id = $reponse['id']; $user = userfromid($reponse['auteur']); $pseudo = $user['pseudo']; $vote = $reponse['nbrvotes']; echo "<div class='row'>\n <div class='col-md-1' >{$pseudo}</div>\n <div class='col-md-8'>{$contenu}</div>\n <div class='col-md-1'>+{$vote}</div>"; if ($reponse['auteur'] == $_SESSION['userid']) { echo "<div class='col-md-2'>\n <a class='a' id='a' href='back_reponses_form.php?edite={$id}'>éditer</a>\n <a class='a' id='b' href='?suppr={$id}'>supprimer</a>\n </div>"; } else { echo "<div class='col-md-2'>\n <a href='back_votes.php?vote={$id}'>voter</a>\n </div>"; } echo "</div>"; } ?>
<?php include "functions.php"; session_start(); testAcces(); if (isset($_POST['contenu'])) { if (isset($_POST['edite'])) { $questionid = $_POST['edite']; $question = question($_POST['edite']); if ($_SESSION['userid'] != $question['auteur']) { die("Accès interdit."); } editeQuestion($_POST['edite'], $_POST['contenu']); $reponses = reponses($questionid); foreach ($reponses as $reponse) { supprVote2($reponse['id']); supprReponse($reponse['id']); } header("Location: back_reponses.php?questionid={$questionid}"); die; } else { if ($_POST['contenu'] == "") { $msg = "Veuillez remplir le champ ci-dessous"; } else { $auteur = $_SESSION['userid']; ajoutQuestion($auteur, $_POST['contenu']); header("Location: back_questions.php"); } } } elseif (isset($_GET['edite'])) { $question = question($_GET['edite']);