-
Notifications
You must be signed in to change notification settings - Fork 2
/
page.php
55 lines (39 loc) · 1.6 KB
/
page.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
<?php
require('config/config.php');
require('config/db.php');
#Delete
if (isset($_POST['delete'])) {
$delete_id = mysqli_real_escape_string($conn, $_POST['delete_id']);
$iquery = "DELETE FROM Book WHERE id={$delete_id}";
if (mysqli_query($conn, $iquery)) {
header('Location: ' . HOME_URL . '');
} else {
echo "Failed, the reason is " . mysqli_error($conn);
}
}
$id = mysqli_real_escape_string($conn, $_GET['id']);
$result = mysqli_query($conn, "SELECT * FROM Book WHERE id = $id ");
$recs = mysqli_fetch_assoc($result);
mysqli_free_result($result);
mysqli_close($conn);
?>
<?php include('inc/header.php') ?>
<body>
<h1 style="text-align:center;">POST</h1>
<div class="container">
<a href="index.php" class="btn btn-primary" style="margin:10px;">Back</a>
<div class="card">
<div class="card-body">
<h1><?php echo $recs['title'] ?></h1>
<small>created at <?php echo $recs['created_at'] ?> by <?php echo $recs['author'] ?></small>
<p><?php echo $recs['body'] ?></p>
<hr>
<form class="float-end" method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="hidden" name="delete_id" value="<?php echo $recs['id'] ?>">
<input type="submit" name="delete" value="Delete" class="btn btn-danger">
</form>
<a href="<?php echo HOME_URL; ?>edit.php?id=<?php echo $recs['id']; ?>" class=" btn btn-primary">Edit</a>
</div>
</div>
</div>
<?php include('inc/footer.php'); ?>