diff --git a/html/data_treatment/AJAXendcheckout.php b/html/data_treatment/AJAXendcheckout.php
index e13b366d47f0ca09f71971bb04ac654f217d8738..4c14365703d9dc21cb453d9ca92dfa5151a198f4 100644
--- a/html/data_treatment/AJAXendcheckout.php
+++ b/html/data_treatment/AJAXendcheckout.php
@@ -52,6 +52,15 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
     $text = "";
     foreach ($decoded_items as $item) {
         // Decode Unicode escape sequences within the itemName
+        $itemName = $item['itemName'];
+        $quantityOrdered = $item['quantity'];
+
+        // Adjust the SQL query based on your table structure
+        $updateQuantitySQL = "UPDATE articles SET quantity = quantity - ? WHERE itemName = ?";
+        $stmt = $conn->prepare($updateQuantitySQL);
+        $stmt->bind_param("is", $quantityOrdered, $itemName);
+        $stmt->execute();
+        $stmt->close();
         $item['itemName'] = json_decode('"' . $item['itemName'] . '"');
         $text .= "- " . $item['quantity'] . " " . $item['itemName'] . " which costs ";
         if ($item['quantity'] >= 16) {
diff --git a/startbootstrap-agency-gh-pages/index.php b/startbootstrap-agency-gh-pages/index.php
index 831b0fc4282145e2dc39b8384d7018f49c74cbf5..aea9ebe320b195b47b12a1dc8e860ee3c54bf073 100644
--- a/startbootstrap-agency-gh-pages/index.php
+++ b/startbootstrap-agency-gh-pages/index.php
@@ -233,7 +233,9 @@ error: function (error) {
         </section>
 
     <?php 
-    $sql = "select * from articles";
+ 
+    $sql = "SELECT * FROM articles WHERE quantity > 0";
+
     $result = $conn->query($sql);
     $articles = array();
     while ($row = $result->fetch_assoc()) {
@@ -313,6 +315,8 @@ error: function (error) {
                                     <img class="img-fluid d-block mx-auto" src=<?php echo "'../image/laptops/".$articles[$i]["imagename"]."'"; ?> alt="..." />
                                     <p><?php echo $articles[$i]["description"]; ?></p>
                                     <p><?php echo "Price: ".$articles[$i]["price"]." € <br>Quantity available: ".$articles[$i]["quantity"];?></p>
+                                    <input type="hidden" id=hiddenquantity value=<?php echo $articles[$i]["quantity"];?>>
+                                    <?php if(isset($_SESSION["username"])){?>
                                     <div class="quantity">
                                         <button onclick="decrementQuantity(this)">-</button>
                                         <input type="text" value="1" <?php echo 'id="quantity'.$i.'"'; ?>>
@@ -325,12 +329,15 @@ error: function (error) {
                                             onclick="addToCart(this)">
                                             Add to shopping cart
                                         </button>
-
+                                    <?php } ?>
                                         <script>
                                             function incrementQuantity(button) {
                                                 var input = button.parentNode.querySelector('input');
+                                                var quantity = parseInt(button.parentNode.parentNode.querySelector('input[type="hidden"]').value,10);
                                                 var value = parseInt(input.value, 10);
+                                                if(value+1<= quantity){
                                                 input.value = value + 1;
+                                                }
                                             }
 
                                             function decrementQuantity(button) {
diff --git a/startbootstrap-agency-gh-pages/purchased_item.php b/startbootstrap-agency-gh-pages/purchased_item.php
index 2eb7d5d77ce42b3fcbc528cc39bd48ab7fa0e6e4..806445422a4eb06f6079616e99c12e9f6dc9b7e6 100644
--- a/startbootstrap-agency-gh-pages/purchased_item.php
+++ b/startbootstrap-agency-gh-pages/purchased_item.php
@@ -1,3 +1,11 @@
+<?php 
+session_start();
+include("../html/data_treatment/update_activity.php");
+if(!isset($_SESSION["username"])){
+    header("location: ../html/login.php");
+    exit;
+} 
+?>
 <button type="button" onclick="redirectToPage()">Return</button> <br><br><br>
 
 <script>
diff --git a/startbootstrap-agency-gh-pages/shoppingPage.php b/startbootstrap-agency-gh-pages/shoppingPage.php
index 2c8001881d9ff7f6766951166a4c45363cf2e873..ec13468e891ea120216ccc3950aeabb9a93e9e5a 100644
--- a/startbootstrap-agency-gh-pages/shoppingPage.php
+++ b/startbootstrap-agency-gh-pages/shoppingPage.php
@@ -83,11 +83,21 @@ while ($row = $result->fetch_assoc()) {
                 </div>
             </div>
         </section>
-        <?php foreach($_SESSION["panier"] as $item){ ?>
+        <?php foreach($_SESSION["panier"] as $item){
+            $sql = "SELECT * FROM articles WHERE quantity > 0 AND itemName = '" . $item["itemName"] . "'";
+
+
+            $result = $conn->query($sql);
+            $articles = array();
+            while ($row = $result->fetch_assoc()) {
+                $articles[] = $row;
+            }
+             ?>
             <div class="product">
                 <img <?php echo 'src="../image/laptops/'.$item['imagename'].'"'?> style="width:10%">
                 <h2><?php echo $item["itemName"];?></h2>
                 <input type="hidden" value="<?php echo $item["price"];?>" id=unitprice-<?php echo $item["itemName"];?>>
+                <input type="hidden" id=hiddenquantity value=<?php echo $articles[0]["quantity"];?>>
                 <p id="price-<?php echo $item["itemName"]; ?>" data-price="<?php echo $item["price"]; ?>">
                 <?php if($item['quantity']>=16){
                     echo "Price: ".$item["price"]*$item["quantity"]*(1-0.16)." € (16% discount)";
@@ -127,10 +137,16 @@ while ($row = $result->fetch_assoc()) {
             function incrementQuantity(button, itemName) {
                 var input = button.parentNode.querySelector('input');
                 var value = parseInt(input.value, 10);
-                input.value = value + 1;
+                var maxquantity = parseInt(button.parentNode.parentNode.querySelector('input[type="hidden"]:nth-of-type(2)').value,10);
+                console.log(maxquantity);
+                if(value+1<= maxquantity){
+                    input.value = value + 1;
+                }
                 updateQuantity(itemName, input.value);
                 var price = button.parentNode.parentNode.querySelector('p');
                 var unitprice = button.parentNode.parentNode.querySelector('input[type="hidden"]');
+                
+
                 if(input.value>=16){
                     price.innerText = "Price: "+parseInt(unitprice.value,10)*input.value*(1-0.16)+" € (16% discount)";
                 } else if(input.value>=8){
diff --git a/startbootstrap-agency-gh-pages/thank_you_page.php b/startbootstrap-agency-gh-pages/thank_you_page.php
index 4ab12014fab3852d2da343bf15e985cbb1ef8586..8390de5a21d2bd7d1e64ff1bf800e5dce1251bc9 100644
--- a/startbootstrap-agency-gh-pages/thank_you_page.php
+++ b/startbootstrap-agency-gh-pages/thank_you_page.php
@@ -1,3 +1,11 @@
+<?php
+session_start();
+include("../html/data_treatment/update_activity.php");
+if(!isset($_SESSION["username"])){
+    header("location: ../html/login.php");
+    exit;
+}  
+?>
 <!DOCTYPE html>
 <html lang="en">