diff --git a/productpage.php b/productpage.php index 81592c1..0f15db5 100644 --- a/productpage.php +++ b/productpage.php @@ -73,10 +73,35 @@ $productId = isset($_GET['id']) ? (int)$_GET['id'] : 0; ?> 0 && $alreadyInWishlist == null) { + + $stmtFav = mysqli_prepare( + $conn, + "INSERT IGNORE INTO userFavorites (productID, userID) VALUES (?, ?)" + ); + + if ($stmtFav) { + mysqli_stmt_bind_param($stmtFav, 'ii', $productIdPost, $userId); + mysqli_stmt_execute($stmtFav); + mysqli_stmt_close($stmtFav); + $alreadyInWishlist = true; + } + } + } ?> +