Beispiel #1
0
    $bidDate = $date = date('Y-m-d');
    $bidPrice = $_POST['bidPrice'];
    if ($bidPrice < $auctionItemRow['startPrice'] || $bidPrice <= $highestBid[0]) {
        echo '
			<div class = "alert alert-danger">
				Error bidding - bid price must be higher than start price or highest bid!
			</div>
		';
    } else {
        //get starting price, if bidprice<starting price then show error.
        //$bidQuery = "INSERT INTO `bids` (`auctionID`, `userId`, `bidPrice`, `bidDate`) VALUES ('$auctionID', '$userId', '$bidPrice', '$bidDate')";
        //update auction bid count
        //$updateQuery = "UPDATE `auction` SET bids = bids+1 WHERE auctionID='$auctionID'";
        //auction manager
        $auction = new Auction($conn);
        if ($auction->addBid($auctionID, $userId, $bidPrice, $bidDate)) {
            echo '
				<div class = "alert alert-success">
					Bid successful
				</div>
			';
            //notifyBidders($auctionID, $bidPrice, $bidDate, $userId)
            $auction->notifyBidders($auctionID, $bidPrice, $bidDate, $userId);
        } else {
            echo '
				<div class = "alert alert-danger">
					Error bidding
				</div>
			';
        }
    }