Hello;
I have a inquiry basket system that works just like shopping basket system. It works like a user can add multiple items to inquiry basket to later fillout a simple form to send multiple inquiries to many users. My system has both free and premium memberships. But free members can exploit this inquiry basket to send spam messages to other users. So I want to implement a feature so that free members can not add more than 3 items in inquiry basket at a time. So I am placing here the source code of my cart/inquiry basket.
<?php
include_once('myconnect.php');
if( !isset($_REQUEST["sb_id"]) || !is_numeric($_REQUEST["sb_id"]) || ($_REQUEST["sb_id"] <= 0) || !isset($_REQUEST["sb_type"]) || !is_numeric($_REQUEST["sb_type"]) || ($_REQUEST["sb_type"] <= 0) || ($_REQUEST["sb_type"] > 3))
{
header("Location: gen_confirm.php?errmsg=".urlencode("Invalid access, denied"));
die();
}
$sb_id=$_REQUEST["sb_id"];
$sb_type=$_REQUEST["sb_type"];
include_once "logincheck.php";
//=======================maintaining cart items=======================================
if(!isset($_SESSION["offer_count"]))
{
$_SESSION["offer_count"]=0;
}
switch($sb_type)
{
case 1:
for($i=0;$i<=$_SESSION["offer_count"];$i++)
{
if((isset($_SESSION["sell_offer_".$i]))&&($_SESSION["sell_offer_".$i]==$sb_id))
{
header("Location:"."gen_confirm.php?sb_type=$sb_type&id=$sb_id&errmsg=".urlencode("Sell Offer is
already in the inquiry basket"));
die();
}
}
case 2:
for($i=0;$i<=$_SESSION["offer_count"];$i++)
{
if((isset($_SESSION["buy_offer_".$i]))&&($_SESSION["buy_offer_".$i]==$sb_id))
{
header("Location:"."gen_confirm.php?sb_type=$sb_type&id=$sb_id&errmsg=".urlencode("Buy Offer is
already in the inquiry basket"));
die();
}
}
case 3:
for($i=0;$i<=$_SESSION["offer_count"];$i++)
{
if((isset($_SESSION["catalog_offer_".$i]))&&($_SESSION["catalog_offer_".$i]==$sb_id))
{
header("Location:"."gen_confirm.php?sb_type=$sb_type&id=$sb_id&errmsg=".urlencode("Product Catalog
is already in the inquiry basket"));
die();
}
}
}
$_SESSION["offer_count"]=$_SESSION["offer_count"]+1;
$cnt=$_SESSION["offer_count"];
switch($sb_type)
{
case 1:
session_register("sell_offer_".$cnt);
$_SESSION["sell_offer_".$cnt]=$sb_id;
header("Location:"."gen_confirm.php?sb_type=$sb_type&id=$sb_id&errmsg=".urlencode("Sell Offer has been added to inquiry basket"));
die();
case 2:
session_register("buy_offer_".$cnt);
$_SESSION["buy_offer_".$cnt]=$sb_id;
header("Location:"."gen_confirm.php?sb_type=$sb_type&id=$sb_id&errmsg=".urlencode("Buy Offer has been added to inquiry basket"));
die();
case 3:
session_register("catalog_offer_".$cnt);
$_SESSION["catalog_offer_".$cnt]=$sb_id;
header("Location:"."gen_confirm.php?sb_type=$sb_type&id=$sb_id&errmsg=".urlencode("Product has been added to inquiry basket"));
die();
}
//=======================maintaining cart items=======================================
?>
Please help me in adding the minor code modefication to implement the feature that free members could not add more than 3 items in the cart at a time
Free members can be identified by using the expression:
if ($_SESSION["b2b_memtype"]=="3" )