Пример #1
0
<?php

require_once 'loader.php';
/*
 * Here, you can reply a comments of other users under posts
 */
try {
    if (isset($_POST['nickname']) && isset($_POST['text'])) {
        $nickname = $_POST['nickname'];
        $text = $_POST['text'];
        $comment_id = $_GET['comment_id'];
        if ($nickname != null && $text != null && $comment_id != null) {
            $reply_comment = factory::reply_comment_factory();
            $reply_comment->savetoDB($comment_id, $nickname, $text);
        }
    } else {
        throw new InvalidArgumentException("Nie uzupełniłeś wszystkich pól!");
    }
} catch (Exception $e) {
    echo '<h1 class=" grey text-center">' . $e->getMessage() . '</h1>';
}
if (isset($_GET['comment_id']) && isset($_GET['id'])) {
    $comment_id = $_GET['comment_id'];
    $post_id = $_GET['id'];
    try {
        $stmt = $pdo->prepare('SELECT id,nickname, text  FROM comments WHERE id=' . ':comment_id' . '   ORDER BY id DESC');
        $stmt->bindValue(':comment_id', $comment_id, PDO::PARAM_INT);
        $stmt->execute();
        echo '<div class="post-border well well-lg" style="background-color:rgba(16,16,16,0.95);border:15px solid #272727;"><br><div class="margin-auto comment text-left">';
        while ($row = $stmt->fetch()) {
            echo '<p class="lead text-left" style="color:white;">' . $row['nickname'] . ' napisał: </p>