hope this isnt getting to confusing by doing this
i thought i add some of the code that already exists
is this (poor) pseudo code getting close at all...
if bidcredit = 0
return an error message
if bid_amount > bidcredit
return an error message
else if bid_amount <= bidcredit
it ok to carry on
where should i place a piece of code to check a users credit amount
I.E in the class file or in the main file in the case ?
**************************************************here is the snippet from the main auction file (SNIPPET FROM CLaSS FILE FOLLOWS )******************************
case 8:
//process a bid
//sellers_id is b
include("classes/auction_browse_class.php");
$auction_browse = new Auction_browse($auth_auctions_103);
$auction_browse->auction_close($db);
include("auctionheader.htm");
if (!$auth_auctions_103->auction_user_id)
{
$auth_auctions_103->auth_messages["login"] = $auth_auctions_103->messages[832];
$auth_auctions_103->login_form();
}
else
{
include("classes/auction_bid_class.php");
$bid = new Auction_bid();
if (($b) && ($c))
{
if (!$bid->process_bid($db,$b,$auth_auctions_103->auction_user_id,$c))
{
$bid->bid_error();
}
else
{
//successful bid
if (!$bid->display_successful_bid($db,$b))
{
$bid->bid_error();
}
else
{
if (!$bid->mail_confirmation($db,$b,$auth_auctions_103->auction_user_id))
$bid->bid_error();
}
}
}
elseif ($b)
{
if (!$bid->prepare_bid($db,$auth_auctions_103->auction_user_id,$b))
{
$bid->bid_error();
}
}
else
{
$bid->error_message = $bid->messages[2312];
$bid->bid_error();
}
}
include("auctionfooter.htm");
exit;
break;
*************************************************SNIPPET FROM THE AUCTION_BID_CLASS file FUNCTION PROCESS BID if the whole code is needed ask 🙂 ********
function process_bid($db,$auction_id=0,$bidder=0,$bid_amount=0)
{
if ($auction_id)
{
if ($bidder)
{
if ($bid_amount)
{
//check to if bid_amount is above or = to the minimum bid
$sql_query = "select * from ".$this->auctions_table." where id = ".$auction_id;
//echo $sql_query." is the query<br>\n";
$result = &$db->Execute($sql_query);
if (!$result)
{
//echo $sql_query." is the query<br>\n";
$this->error_message = $this->messages[2313];
return false;
}
elseif ($result->RecordCount() == 1)
{
$show = $result->FetchNextObject();