-
Notifications
You must be signed in to change notification settings - Fork 0
/
addtowishlist.php
36 lines (34 loc) · 1 KB
/
addtowishlist.php
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
<?php
require_once("includes/constants.php");
require_once CRUD;
session_start();
if((isset($_GET['pid'])) && (!empty($_SESSION['user_id']))){
require_once VALIDATE;
$pid = base64_decode($_GET['pid']);
$uid = $_SESSION['user_id'];
$added_on = date('Y-m-d');
require_once DB_PATH;
$sql_chk_prod_id = "select wishlist_id from fk_wishlist_tbl where prod_id = $pid and user_id = $uid";
$chk_res = mysqli_query($con,$sql_chk_prod_id);
$count = mysqli_num_rows($chk_res);
if($count==0){
$sql_insert = "insert into fk_wishlist_tbl (prod_id,user_id,added_on) values ($pid,$uid,'$added_on') ";
$res = mysqli_query($con,$sql_insert);
$arr = array('prod_id'=>$pid,'user_id'=>$uid,'added_on'=>$added_on);
$res = my_insert('fk_wishlist_tbl',$arr);
if($res){
$wid = mysqli_insert_id($con);
header('location:index.php');
$succ_msg = "Added to wishlist";
}
else
$err_msg = "Not Added";
}
else{
header('location:index.php');
}
}
else{
header('location:login.php');
}
?>