-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddToWatchlistProcess.php
More file actions
37 lines (26 loc) · 933 Bytes
/
addToWatchlistProcess.php
File metadata and controls
37 lines (26 loc) · 933 Bytes
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
<?php
session_start();
include "connection.php";
if(isset($_SESSION["u"])){
if(isset($_GET["id"])){
$email = $_SESSION["u"]["email"];
$pid = $_GET["id"];
$watchlist_rs = Database::search("SELECT * FROM `watchlist` WHERE `user_email`='".$email."' AND
`product_id`='".$pid."'");
$watchlist_num = $watchlist_rs->num_rows;
if($watchlist_num == 1){
$watchlist_data = $watchlist_rs->fetch_assoc();
$list_id = $watchlist_data["w_id"];
Database::iud("DELETE FROM `watchlist` WHERE `w_id`='".$list_id."'");
echo ("removed");
}else{
Database::iud("INSERT INTO `watchlist`(`user_email`,`product_id`) VALUES ('".$email."','".$pid."')");
echo ("added");
}
}else{
echo ("Something went wrong. Please try again later.");
}
}else{
echo ("Please Login First.");
}
?>