-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviewPost.php
More file actions
89 lines (81 loc) · 2.62 KB
/
viewPost.php
File metadata and controls
89 lines (81 loc) · 2.62 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
<?php require_once 'inc/connection.php' ?>
<?php require_once 'inc/function.php' ?>
<?php require_once 'inc/header.php' ?>
<?php
$post=[];
if (isset($_GET['id'])&&is_numeric($_GET['id'])) {
$id=$_GET['id'];
//to check is found in database
$query="select posts.*, users.name from posts join users
on posts.user_id=users.id
where posts.`id`=$id";
$runQuery=mysqli_query($conn,$query);
if(mysqli_num_rows($runQuery)==1){
$post= mysqli_fetch_assoc($runQuery);
}
//if not found this id in database
else{
echo "not found";
header("location:index.php");
}
}
else {
header("location:index.php");
}
?>
Page Content
<div class="page-heading products-heading header-text">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="text-content">
<h4><?=$mes['View Post']?></h4>
<h2><?=$mes['view personal post']?></h2>
</div>
</div>
</div>
</div>
</div>
<?php
/*
if(isset($_SESSION['success'])){
printSuccessMessage($_SESSION['success']);
unset($_SESSION['success']);
}
*/
?>
<div class="best-features about-features">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="section-heading">
<h2 class=<?php if($_SESSION['lang']=='ar') echo"text-end"?>><?=$mes['Our Post Image']?></h2>
</div>
</div>
<?php if(isset($_SESSION['success'])){
printSuccessMessage($_SESSION['success']);
unset($_SESSION['success']);
}?>
<div class="col-md-6">
<div class="right-image">
<img src="upload/<?=$post['image'];?>" alt="">
</div>
</div>
<div class="col-md-6 " >
<div class="left-content">
<h4><?=$post['title'];?></h4>
<p><?=$post['body'];?>.</p>
<div class="author">
<p><?=$mes['Author']?> <?=$post['name'];?></p>
</div>
<?php if(isset($_SESSION['login'])):?>
<div class="d-flex justify-content-center">
<a href="editPost.php?id=<?=$post['id'];?>" class="btn btn-success mr-3 "> edit post</a>
<a href="handle/deletePost.php?id=<?=$id;?>" class="btn btn-danger "> delete post</a><?php endif; ?>
</div>
</div>
</div>
</div>
</div>
</div>
<?php require_once 'inc/footer.php' ?>