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

require_once 'loader.php';
/*
 * Saving a new comment to database
 */
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $nickname = $_POST['nickname'];
    $text = $_POST['text'];
    $post_id = $_GET['id'];
    try {
        if ($nickname != null && $text != null && $post_id != null) {
            $comment = factory::comments_factory();
            $comment->savetoDB($post_id, $nickname, $text);
            $stmt = $pdo->query('SELECT id,nickname, text  FROM comments WHERE post_id=' . $post_id . '   ORDER BY id DESC');
            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;line-height: 1px;">' . $row['nickname'] . ' napisał: </p>
                    ' . "<a href=http://projects.e-kei.pl/inba/reply_comment.php?comment_id=" . $row['id'] . " style=\"text-decoration: none;\"><p class=\"grey\" style=\"font-size:9px;\">" . '(odpowiedz/zobacz wszystkie odpowiedzi)</p></a>' . '<p class="text-left" style="color:white;line-height: 1cm;">' . $row['text'] . '</p>
                <hr><div class="clear"></div>';
            }
            echo '</div></div>';
            $stmt->closeCursor();
        } else {
            throw new InvalidArgumentException("Nie uzupełniłeś wszystkich pól!");
        }
    } catch (Exception $e) {
        echo '<h1 class=" grey text-center">' . $e->getMessage() . '</h1>';
    }
    echo "<br /><br /><button class=\"btn btn-primary btn-lg\" type=\"button\"><a href=\"http://projects.e-kei.pl/inba\" class=\"white\">Powrót do strony głównej</a></button>";
} else {