-
Notifications
You must be signed in to change notification settings - Fork 0
/
item.php
executable file
·152 lines (144 loc) · 6.05 KB
/
item.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<html>
<head>
<title>
Online Shoping
</title>
</head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous">
</script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous">
</script>
<link rel="stylesheet" type="text/css" href="css/style.css">
<link rel="stylesheet" type="text/css" href="css/item.css">
<link rel="stylesheet" href="css/style.css">
<?php require_once('dbConnect.php');
session_start();
$user = $_SESSION["username"];
?>
<body>
<div>
<nav class="nav-bar">
<div class="container" style="height:inherit">
<div class="row">
<div class="col-1" style="height:inherit">
<h3 style="height:inherit; line-height :inherit"> <a href="/home.php">Logo</a></h3>
</div>
<div class="col">
<form class="form-inline" action="/home.php" method="GET" style="height:100%;">
<div class="col-9">
<div>
<input type="text" class=" w-100 rounded search-box" id="search" name="Search"
placeholder="search">
</div>
</div>
<div class="col">
<button type="submit"
class="btn btn-primary w-100 rounded search-button">Search</button>
</div>
</form>
</div>
<div class="col-1 text-right"> <a href="logout.php">logout</a> </div>
<div class="col-1 text-right"> <a href="/cart">cart</a> </div>
<div class="col-1 text-right"> <a href="/orderPage.php">Orders</a> </div>
</div>
</div>
</nav>
</div>
<div class="container item-page">
<br>
<?php
$url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$parts = parse_url($url,PHP_URL_QUERY);
parse_str($parts, $query);
$pid = $query["id"];
$sql = "SELECT * FROM Product WHERE productID = $pid;";
$result = mysqli_query($conn,$sql);
$item = @$result->fetch_array();
$name = $item["ProductName"];
$price = $item["Price"];
$quantity = $item["Product_Quantity"];
$des = $item["Decription"];
$img = $item["Image"];
?>
<div class="row mb-4">
<?php
echo "
<div class='col-4'>
<img src='$img' alt='...' class='item-img2'>
</div>
<div class='col'>
<div>
<h3> $name </h3>
<h5> $price </h5>
<p> Quantity Available : $quantity </p>
<hr>
<p>
$des
</p>
<hr>
";
if($quantity>0){
echo "
<form action='order.php' method='POST'>
<div>
<br>
<label for='item-quantity'>Quantity</label>
<input type='number' id='item-quantity' name='item-quantity' class='quantity-box' value='1' max = '$quantity' min = '1' name='quantity'>
<input type='text' value='$pid ' hidden name='pid' hidden>
<input type='text' name='userID' hidden value ='$user'>
<br>
<br>
<button class='submit-button btn btn-success' name='order' type='submit' value='buy' > BUY </button>
<button class='submit-button btn btn-warning' name='order' type='submit' value='cart' > Add to cart </button>
</div>
</form>";
}else{
echo " <br> <h3> Out of Stock </h3>";
}
echo "
</div>
</div>";
?>
</div>
<div class="row">
<div class="col">
<div>
<h3>Comments</h3>
<hr>
<div>
<form method="POST" action="/comments.php" >
<input type='text' name='userID' hidden value ="<?php $user?>">
<input type="text" value='<?php echo $pid ?>' hidden name='pid'>
<input type='text' class="comment-box" name="comment" autocomplete="off" >
<button type="submit">Submit</button>
</form>
</div>
<ul>
<br>
<br>
<?php
$sql = "SELECT * FROM Comment WHERE productID = $pid";
$result = mysqli_query($conn,$sql);
while($row = @$result->fetch_array()){
$cmt = $row["Comment_text"];
$user = $row["Customer_UserName"];
echo "<p>";
echo "<b class='pr-4'> $user: </b>";
echo "<i> $cmt </i>";
echo "</p>";
}
?>
</ul>
</div>
</div>
</div>
</div>
</body>
</html>