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