-
Notifications
You must be signed in to change notification settings - Fork 1
/
product-remove.php
59 lines (46 loc) · 1.53 KB
/
product-remove.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
<?php $isThisHome = false ?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php require_once './includes/head.php' ?>
<title><?= $app ?></title>
</head>
<?php
if (empty($user)) {
$_SESSION['flash']['info'] = 'You are not logged in!';
return header('Location: /login.php');
}
if ($user->role !== 'manager') {
unset($_SESSION['user']);
$_SESSION['flash']['info'] = 'You are not authorized!';
return header('Location: /login.php');
}
$productId = trim($_GET['id']);
if (empty($productId)) {
return header('Location: /index.php');
}
// $db is coming from ./includes/head.php
$conn = $db->getConnection();
$stmt = $conn->prepare('SELECT * FROM `products` WHERE `id` = :id LIMIT 1');
$stmt->bindParam(':id', $productId);
$stmt->execute();
$product = $stmt->fetch();
?>
<body>
<?php require_once './includes/nav.php' ?>
<main class="container">
<section class="row mt-5">
<form action="/product-delete.php" method="post" class="col-md-6 col-lg-4">
<h3 class="mb-3">Remove Product: <?= $product->title ?></h3>
<p class="text-danger">Are you sure?</p>
<input type="hidden" name="id" value="<?= $product->id ?>">
<div class="d-flex justify-content-between">
<button type="submit" class="btn btn-dark">Remove</button>
<a href="/index.php" class="btn btn-light">Cancel</a>
</div>
</form>
</section>
</main>
<?php require_once './includes/foot.php' ?>
</body>
</html>