-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddToWatchlistProcess.php
More file actions
39 lines (26 loc) · 917 Bytes
/
addToWatchlistProcess.php
File metadata and controls
39 lines (26 loc) · 917 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
38
39
<?php
session_start();
require "includes/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 `product_id`='" . $pid . "' AND
`user_email`='" . $email . "'");
$watchlist_num =$watchlist_rs->num_rows;
if($watchlist_num == 1){
$watchlist_data = $watchlist_rs->fetch_assoc();
$list_id = $watchlist_data["id"];
Database::iud("DELETE FROM `watchlist` WHERE `id`='".$list_id."'");
echo ("removed");
}else{
Database::iud("INSERT INTO `watchlist`(`product_id`,`user_email`) VALUES ('" . $pid . "','" . $email . "')");
echo ("added");
}
}else{
echo ("Something Went Wrong");
}
}else{
echo ("Please Login First");
}
?>