-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbposts.php
More file actions
179 lines (178 loc) · 10.3 KB
/
bposts.php
File metadata and controls
179 lines (178 loc) · 10.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<?php include "root/db.php" ?>
<?php include "root/header.php" ?>
<!-- Preloader -->
<div class="preeloader">
<div class="preloader-spinner"></div>
</div>
<!-- End Preloader -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#commentss").submit(function(){
alert("Comment posted successfully! It will be published online after admin approval.");
});
});
</script>
<!-- Color Plate -->
<div class="color-plate ">
<a class="color-plate-icon"><i class="fa fa-cog fa-spin"></i></a>
<h4>Pantheon Deepsight</h4>
<p>Here are same other awesome theme colors.</p>
<span class="color1"></span>
<span class="color2"></span>
<span class="color3"></span>
<span class="color4"></span>
</div>
<!-- /End Color Plate -->
<!--Navigation-->
<?php include "root/nav2.php" ?>
<!--Breadcrumbs-->
<div class="breadcrumbs">
<div class="container">
<div class="row">
<div class="col-12">
<div class="bread-inner">
<ul class="bread-list">
<li><a href="index.php">Home<i class="lni lni-arrow-right"></i></a></li>
<li class="active"><a href="blog.php">Blog Posts</a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
<!--Blog Posts-->
<!-- Start Blog Area -->
<section class="blog-single section">
<div class="container">
<?php include "root/searchbar.php"; ?>
<div class="row">
<div class="col-lg-10 offset-lg-1 col-12">
<div class="blog-single-main">
<div class="row">
<div class="col-12">
<div class="blog-detail">
<?php
if (isset($_GET['p_id'])) {
$post_id = $_GET['p_id'];
}
$query = "SELECT * FROM posts WHERE post_id = {$post_id}";
$select_all_posts_query = mysqli_query($connection,$query);
while($row = mysqli_fetch_assoc($select_all_posts_query)) {
$post_title = $row['post_title'];
$post_category_id = $row['post_category_id'];
$post_author = $row['post_author'];
$post_date = $row['post_date'];
$post_image = $row['post_image'];
$post_content = $row['post_content'];
$query = "SELECT * FROM categories WHERE cat_id = {$post_category_id}";
$sidebar_query = mysqli_query($connection,$query);
?>
<h2 class="blog-title"><?php echo $post_title; ?></h2>
<div class="blog-meta">
<span class="author"><a href="login.php"><i class="fa fa-user"></i><?php echo $post_author; ?></a><a href="#"><i class="fa fa-calendar"></i><?php echo $post_date; ?></a></span>
</div>
<div class="content">
<?php echo $post_content; ?>
</div>
</div>
<div class="share-social">
<div class="row">
<div class="col-12">
<div class="content-tags">
<h4>Tags:</h4>
<ul class="tag-inner">
<?php
while($row = mysqli_fetch_assoc($sidebar_query)) {
$cat_title = $row['cat_title'];
$cat_id = $row['cat_id'];
echo "<li><a href='category.php?category={$cat_id}'>{$cat_title}</a></li>";
}
?>
</ul>
</div>
</div>
</div>
</div>
<?php } ?>
</div>
<!-- POST -->
<div class="col-12">
<div class="comments">
<h3 class="comment-title">Comments:</h3>
<!-- Single Comment -->
<?php
if (isset($_GET['p_id'])) {
$comment_id = $_GET['p_id'];
}
$query = "SELECT * FROM comments WHERE comment_post_id = {$comment_id} ";
$query .= "AND comment_status = 'Approved' ";
$query .= "ORDER BY comment_id ASC";
$comments_query = mysqli_query($connection,$query);
if(!$comments_query) {
die("COULD NOT UPLOAD COMMENTS." . mysqli_error($connection));
}
while($row = mysqli_fetch_assoc($comments_query)) {
$comment_author = $row['comment_author'];
$comment_email = $row['comment_email'];
$comment_content = $row['comment_content'];
$comment_date = $row['comment_date'];
$comment_image = $row['comment_image'];
?>
<div class="single-comment">
<img src="img/<?php echo $comment_image; ?>" alt="#">
<div class="content">
<h4><?php echo $comment_author; ?> <span>At <?php echo $comment_date; ?></span></h4>
<p><?php echo $comment_content; ?></p>
<div class="button">
<a href="#comment" class="btn"><i class="fa fa-reply" aria-hidden="true"></i>Reply</a>
</div>
</div>
</div>
<?php } ?>
<!-- End Single Comment -->
</div>
</div>
</div>
<div id="comment" class="col-12">
<?php
if(isset($_POST['create_comment'])) {
$comment_post_id = $_GET['p_id'];
$comment_author = $_POST['comment_author'];
$comment_email = $_POST['comment_email'];
$comment_content = $_POST['comment_content'];
$query = "INSERT INTO comments(comment_post_id, comment_author, comment_email, comment_content, comment_status, comment_date) ";
$query .= "VALUES({$comment_post_id},'{$comment_author}','{$comment_email}','{$comment_content}','Unapproved', now() )";
$create_comment_query = mysqli_query($connection,$query);
if (!$create_comment_query) {
die('Server disrupted.' . mysqli_error($connection));
}
}
?>
<div class="reply">
<div class="reply-head">
<h2 class="reply-title">Leave a Comment:</h2>
<!-- Comment Form -->
<form id="commentss" action="" method="post" role="form">
<div class="form-group">
<label for="comment_author">Name:</label>
<input class="form-control" type="text" name="comment_author" value="<?php echo $_SESSION['user_fname'] . " " . $_SESSION['user_lname']; ?>" required="required">
</div>
<div class="form-group">
<label for="comment_email">Email:</label>
<input class="form-control" type="email" name="comment_email" value="<?php echo $_SESSION['user_email']; ?>" required="required">
</div>
<div class="form-group">
<label for="comment_content">Your Comment:</label>
<textarea class="form-control" rows="1" name="comment_content" required="required"></textarea>
</div>
<button type="submit" name="create_comment" class="btn btn-primary">Comment</button>
</form>
<!-- End Comment Form -->
</div>
</div>
</div>
</section>
<!-- End Blog Area -->
<!--Footer-->
<?php include "root/footer.php" ?>