Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $c_text = $_POST['ctext'];
- $c_submit = $_POST['to_comment'];
- $date = R::isoDateTime();
- if ( isset($c_submit) ) {
- $com = R::dispense( 'comments' );
- $com->user_id = $_SESSION['logged_user']->id;
- $com->text = "$c_text";
- $com->publicated = $date;
- $to_com = R::store( $com );
- $about_users = array();
- $about_user = R::findOne( 'users', 'id = ?', [$_SESSION['logged_user']->id]);
- $about_users[] = $about_user;
- $com_num = R::count('comments');
- }
- ?>
- <div class="wide_comments">
- <div class="comments">
- <?php for($i=$com_num-1; $i!=-1; $i--) { foreach($about_users as $ckey) { ?>
- <div class="comment">
- <img class="com_img" href="../img/<?php echo $ckey['avatar']; ?>">
- <p class="com_user"><?php echo $ckey['login']; ?></p>
- <div class="com_text"><?php echo $c_text; ?></div>
- </div>
- <?php }} ?>
- </div>
- </div>
- <?php if ( isset($_SESSION['logged_user']) ) { ?>
- <div class="wide_write">
- <div class="write_comment">
- Добавьте свой комментарий:
- <br>
- <form method="post" action="article.php?id=<?php echo (int) $_GET['id']; ?>">
- <textarea class="write_area" name="ctext"></textarea>
- <br>
- <button class="write_button" name="to_comment">Отправить</button>
- </form>
- </div>
- </div>
- <?php
- } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement