-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwishlist.php
More file actions
120 lines (93 loc) · 3.86 KB
/
Copy pathwishlist.php
File metadata and controls
120 lines (93 loc) · 3.86 KB
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
<?php
include('config.php');
session_start();
$user_id = $_SESSION['user_id'];
if(!isset($user_id)){
header('location:login.php');
}
if(isset($_POST['add_to_cart'])){
$picture_id = $_POST['picture_id'];
$picture_author = $_POST['picture_author'];
$picture_title = $_POST['picture_title'];
$picture_price = $_POST['picture_price'];
$image_picture = $_POST['image_picture'];
$picture_quantity = 1;
$check_cart_numbers= mysqli_query($conn,"SELECT * FROM cart WHERE author ='$picture_author' AND user_id = '$user_id'");
if( mysqli_num_rows($check_cart_numbers) > 0){
$message[] = 'Already add to cart';
}
else{
$check_wishlist_numbers = mysqli_query($conn , "SELECT * FROM wishlist WHERE author='$picture_author' AND user_id = '$user_id'");
if( mysqli_num_rows($check_wishlist_numbers) > 0){
mysqli_query($conn , "DELETE FROM wishlist WHERE author='$picture_author' AND user_id = '$user_id'");
}
mysqli_query($conn, "INSERT INTO cart (user_id, picture_id ,author,title,picture_price,quantity ,image_picture)VALUES('$user_id','$picture_id','$picture_author','$picture_title','$picture_price','$picture_quantity','$image_picture')");
$message[]='Picture added to cart';
}
}
if(isset($_GET['delete'])){
$delete_id = $_GET['delete'];
mysqli_query($conn, "DELETE FROM wishlist WHERE id='$delete_id'");
header('location:wishlist.php');
}
if(isset($_GET['delete_all'])){
mysqli_query($conn, "DELETE FROM wishlist WHERE user_id ='$user_id'");
header('location:wishlist.php');
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Wishlist</title>
<!-- css file link -->
<link rel="stylesheet" href="css/mainstyle.css"/>
<!-- font awesome cdn link -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css"/>
</head>
<body>
<?php
include('header.php');
?>
<section class="wishlist">
<h1 >PICTURES ADDED</h1>
<div class="box-container">
<?php
$grand_total = 0;
$select_wishlist= mysqli_query($conn,"SELECT * FROM `wishlist` WHERE user_id = '$user_id'");
if(mysqli_num_rows($select_wishlist) > 0) {
while($fetch_wishlist = mysqli_fetch_assoc($select_wishlist)){
?>
<form action="" method="POST" class="box">
<a href="wishlist.php?delete=<?php echo $fetch_wishlist['id']; ?>" class="fas fa-times" onclick="return confirm('delete this from wishlist?');"></a>
<img src="imgpicture/<?php echo $fetch_wishlist['image_picture']; ?>" alt="" class="image">
<div class="author"><?php echo $fetch_wishlist['author']; ?></div>
<div class="title"><?php echo $fetch_wishlist['title']; ?></div>
<div class="picture_price">€<?php echo $fetch_wishlist['picture_price']; ?></div>
<input type="hidden" name="picture_id" value="<?php echo $fetch_wishlist['picture_id']; ?>">
<input type="hidden" name="picture_author" value="<?php echo $fetch_wishlist['author']; ?>">
<input type="hidden" name="picture_title" value="<?php echo $fetch_wishlist['title']; ?>">
<input type="hidden" name="picture_price" value="<?php echo $fetch_wishlist['picture_price']; ?>">
<input type="hidden" name="image_picture" value="<?php echo $fetch_wishlist['image_picture']; ?>">
<!-- butonat -->
<input type="submit" value="add to cart" name="add_to cart" class="btn">
</form>
<?php
$grand_total += $fetch_wishlist['picture_price'];
}
}
else{
echo '<p class="empty">Your WISHLIST is empty</p>';
}
?>
<div class="wishlist-total">
<p>Total Price: <span>€<?php echo $grand_total; ?></span></p>
<a href="shop.php" class="option-btn">Continue Shopping</a>
<a href="wishlist.php?delete_all" class="delete-btn <?php echo ($grand_total > 1 )?'':'disabled' ?> "onclick="return confirm('Delete all from wishlist?');">DELETE ALL</a>
</div>
</section>
<?php
include('footer.php');
?>
<script scr="Js/script.js"></script>
</body>
</html>