-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhome.php
80 lines (61 loc) · 2.05 KB
/
home.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
<?php
session_start();
// $uname = $_SESSION["username"];
// echo "Hello, $uname";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Pinky Lulu Shop</title>
</head>
<body>
<?php
if (isset($_SESSION['username']) == false) {
// <!-- belum punya akun -->
header("location: ./login.php");
} else {
if ($_SESSION["username"] == 'admin') {
?>
<a href="./confirmation.php"> Confirmation </a>
<a href="./insert.php"> Insert </a>
<?php
}
?>
<a href="./cart.php"> Cart </a>
<a href="./pendingpayment.php"> Payment Information</a>
<a href="./controller/doLogout.php"> Sign out </a>
<?php
}
?>
<?php
include "./database/dbProduct.php";
$query = "SELECT * FROM product";
$result = $connection->query($query);
//list semua product yg tersedia
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
?>
<p><b> <?= $row["nama"]; ?> </b></p> <!-- Show smartphone brand from database -->
<!-- Image from path public/image/product/{image} -->
<!-- <center> -->
<img src="./asset/image/product/<?= $row["gambar"]; ?>" class="img-responsive" alt="Image"> <!-- {image} = image from database -->
<!-- </center> -->
<br>
Stock :
<?= $row["stock"]; ?>
<!-- Show smartphone type from database -->
<p>Rp <?= $row["harga"]; ?></p> <!-- Show smartphone price from database -->
<!-- Show Button Update and Delete -->
<?php if ($_SESSION["username"] === "admin") { ?>
<a class="btn btn-warning" href="./update.php?id=<?= $row["id"]; ?> ">Update</a>
<a class="btn btn-danger" href="./controller/doDelete.php?id=<?= $row["id"]; ?>">Delete</a>
<?php }else{ ?>
<a class="btn btn-warning" href="./buy.php?id=<?= $row["id"]; ?> ">Buy</a>
<?php }
}
} ?>
</body>
</html>