-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpost.php
183 lines (162 loc) · 10.3 KB
/
post.php
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
180
181
182
183
<?php
include("includes/header.php");
?>
<?php
include("includes/navbar.php");
?>
<div class="container-fluid" >
<div class="row" >
<!-- start of main post content area-->
<div class="col l9 m9 s12" >
<?php
if(isset($_GET["id"]))
{
$id=$_GET["id"];
$id=mysqli_real_escape_string($con,$id);
$id=htmlentities($id);
$sql="SELECT * FROM posts p, users u WHERE p.author=u.id AND p.id=$id";
$res=mysqli_query($con,$sql);
if(mysqli_num_rows($res)>0)
{
$sql="select ";
$row=mysqli_fetch_assoc($res);
$title=$row["title"];
$content=$row["content"];
$views=$row["view"];
//echo $views;
$sql1="UPDATE posts SET view=view+1 WHERE id=$id";
mysqli_query($con,$sql1);
?>
<div class="card-panel">
<div class="collection teal center with-header" style="background-image: linear-gradient(#acb6e5,#74ebd5 );border-radius: 5px;">
<h5 class="teal white-text" style="background-image: linear-gradient(#acb6e5,#74ebd5 );border-radius: 5px;"><?php echo ucwords($title);?></h5>
</div>
<h5 style="background-image: linear-gradient(#74ebd5,#acb6e5 );border-radius: 5px;padding: 10px;"><b>Author</b> : <?php echo $row["username"]?> <br/><b>Date</b> : <?php echo $row["post_date"];?></h5>
<p class="flow-text">
<?php echo $content;?>
</p>
<div class="card-panel">
<div class="collection teal center with-header" style="background-image: linear-gradient(#acb6e5,#74ebd5 );border-radius: 5px;">
<h5 class="white-text">Write comments to us</h5>
</div>
<div class="center">
<?php
if(isset($_SESSION["message"]))
{
echo $_SESSION["message"];
unset($_SESSION["message"]);
}
?>
</div>
<div class="row ">
<div class="col l8 offset-l2 m10 offset-m1 s12 ">
<form action="addComment.php?id=<?php echo $id?>" method="post">
<div class="input-field">
<input type="email" name="email" id="" placeholder="Enter Email" class="validate">
<label for="email" data-error="Invalid email format"></label>
</div>
<div class="input-field">
<textarea name="comment_text" class="materialize-textarea" placeholder="Your comment goes here..."></textarea>
</div>
<div class="center">
<input type="submit" value="Comment" name="comment" class="btn">
</div>
</form>
<div class="collection teal center with-header" style="background-image: linear-gradient(#acb6e5,#74ebd5 );border-radius: 5px;">
<h5 class="white-text">Comments</h5>
</div>
<ul class="collection">
<?php
$sql3="SELECT * FROM comment WHERE postID=$id AND status=1 ORDER BY id DESC";
$res3=mysqli_query($con,$sql3);
if(mysqli_num_rows($res3)>0)
{
while($row=mysqli_fetch_assoc($res3))
{
?>
<li class="collection-item" >
<?php echo $row["comment_text"];?>
<span class="secondary-content">
<?php echo $row["email"]?>
</span>
</li>
<?php
}
}
else
{
?>
<div class="center" style="background-image: linear-gradient(#acb6e5,#74ebd5 );border-radius: 5px;">
<div class="text-flow red white-text">No comments yet .. !</div>
</div>
<?php
}
?>
</ul>
</div>
</div>
</div>
<div class="row">
<!-- start of Related blogs content area-->
<div class="col l12 m12 s12" style="margin-top:10em;background-image: linear-gradient(#74ebd5, #acb6e5);border-radius: 5px;" >
<div class="collection teal center with-header" style="background-image: linear-gradient(#acb6e5,#74ebd5 );border-radius: 5px;">
<h5 class="teal white-text" style="background-image: linear-gradient(#acb6e5,#74ebd5 );border-radius: 5px;">Related Blogs</h5>
</div>
<!-- start of main content area-->
<div class="col l12 m12 s12" >
<?php
$sql="SELECT * FROM posts ORDER BY rand() limit 4";
$res=mysqli_query($con,$sql);
if(mysqli_num_rows($res)>0)
{
while($row=mysqli_fetch_assoc($res))
{
?>
<!-- Card Start from here -->
<div class="col l3 m4 s6" >
<div class="card" style="border-radius: 15px;">
<div class="card-image">
<img src="img/<?php echo $row["feature_image"]?>" alt="" style="height:150px;border-radius: 15px 15px 0px 0px;" class="img-responsive" >
<span class="card-title"><?php echo $row["title"]?></span>
</div>
<div class="card-action teal center" style="background-image: linear-gradient(#74ebd5,#acb6e5 );">
<a href="post.php?id=<?php echo $row['id'];?>" class="white-text" style="background-image: linear-gradient(#acb6e5,#74ebd5 );">Read more...</a>
</div>
</div>
</div>
<!-- Card End from here -->
<?php
}
}
?>
</div>
<!-- start of main content area-->
</div>
<!-- end of Related blogs content area--></div>
</div>
<?php
}
else
{
header("location:index.php");
}
}
else
{
header("location:index.php");
}
?>
</div>
<!-- start of main content area-->
<!-- start of sidebar content area-->
<div class="col l3 m3 s12" >
<?php
include("includes/sidebar.php");
?>
</div>
<!-- end of sidebar content area-->
</div>
</div>
<?php
include("includes/footer.php");
?>