-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgallery_view.php
More file actions
53 lines (46 loc) · 1.8 KB
/
Copy pathgallery_view.php
File metadata and controls
53 lines (46 loc) · 1.8 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
<?php
$title = "View Post";
include "./includes/header.php";
include "./confing.php";
?>
<?php
session_start();
//get the single post
if (isset($_GET['viewId'])) {
$post_id = htmlspecialchars($_GET["viewId"]);
$query = "SELECT * from gallery WHERE id = {$post_id} ";
$result = mysqli_query($db, $query);
$data = mysqli_fetch_assoc($result);
}
//delete post
if (isset($_POST['delete'])) {
$id = htmlspecialchars($_POST["delete_id"]);
$deleteQuery = mysqli_query($db, "DELETE FROM `gallery` WHERE `id`='$id'");
if ($deleteQuery) {
header('Location:gallery.php');
}
}
?>
<div class="container">
<div class="row my-5">
<div class="col-lg-8 mb-4">
<div class="card">
<img class="card-img-top" style="height: 60vh;" src=".<?php echo $data["image"] ?>" alt="image alt">
<div class="card-body">
<h5 class="card-title"><?php echo $data["title"] ?></h5>
<p class="card-text"><?php echo $data["description"] ?></p>
<div class="d-flex justify-content-end">
<?php if (isset($_SESSION["login"])) : ?>
<a href="gallery_edit.php?editId=<?php echo $data["id"] ?>" class="btn btn-info btn-sm mx-2">Edit</a>
<form method="POST" action="<?php echo $_SERVER["PHP_SELF"] ?>">
<input type="text" hidden value='<?php echo $data["id"] ?>' name="delete_id">
<button type="submit" class="btn btn-danger btn-sm ml-2" name="delete">Delete</button>
</form>
<?php endif; ?>
</div>
</div>
</div>
</div>
</div>
</div>
<?php include "includes/bottom.php" ?>