0) { $neighbor_id = isset($_SESSION['neighborId']) && $_SESSION['neighborId']!=''?$_SESSION['neighborId']:''; $couponId = mysql_real_escape_string($_GET['coupon']); if ($neighbor_id != '') //if neighbor is logged I'm adding the clipped coupons in the database { //checking if coupon exists $sql = "select coupon_id from tbl_coupons where coupon_id=".$couponId; $result = dbQuery($sql); // if it exists I'll add it to clipped coupons if (mysql_num_rows($result) > 0) { $sql = "INSERT INTO tbl_clipped_coupons values (".$neighbor_id.",".$couponId.")"; dbQuery($sql); $retUrl = isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:SITE_ROOT.'coupons/'; addCouponViews($couponId); header("Location: $retUrl"); exit(); } } else //if the neighbor is not logged in I'll store the added coupons in $_SESSION { $_SESSION['clipped_coupons'][] = $couponId; $retUrl = isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:SITE_ROOT.'coupons/'; header("Location: $retUrl"); exit(); } } } if ( isset($_GET['view']) && $_GET['view'] == 'removeCoupon' ) { $neighbor_id = isset($_SESSION['neighborId'])?$_SESSION['neighborId']:''; $couponId = mysql_real_escape_string($_GET['coupon']); if ( isset($_GET['coupon']) && $_GET['coupon'] > 0) { if ($neighbor_id != '') //if neighbor is logged I'm adding the clipped coupons in the database { //checking if coupon exists $sql = "select coupon_id from tbl_coupons where coupon_id=".$couponId; $result = dbQuery($sql); if (mysql_num_rows($result) > 0) { $sql = "DELETE from tbl_clipped_coupons where coupon_id = $couponId and neighbor_id = $neighbor_id"; // echo $sql; dbQuery($sql); $retUrl = SITE_ROOT.'coupons/mycoupons/'; header("Location: $retUrl"); exit(); } } else //if the neighbor is not logged in I'll remove the added coupons in $_SESSION { $x = array(); $x[0] = $couponId; $_SESSION['clipped_coupons'] = array_diff($_SESSION['clipped_coupons'],$x); $retUrl = SITE_ROOT.'coupons/mycoupons/'; header("Location: $retUrl"); exit(); } } } if ( isset($_GET['view']) && $_GET['view'] == 'mycoupons' ) { // checkuser("neighbors"); //$neighbor_id = $_SESSION['neighborId']; $couponsIncludedPage = "displayCoupons.php"; } ?> Restaurant Coupons, Discounts, Specials, Bar Specials, Pizza Coupons, Local Deals, Virginia, Washington, DC, Maryland - YardsAway®