我试图在php中放入两个if
语句,但只执行其中一个
<?php
if (isset($_POST["redeembutton"])) {
$redeemedBalance = strip_tags($_POST["vidcoinamount"]);
$actualBalance = get_balance();
if ($actualBalance < $redeemedBalance && $redeemedBalance < 500) { // If trying to redeem what the user don't have OPEN ?>
<span class='greeting'>Sorry, you can't exchange that...</span><br/>
<span class='heading'>You have <?php echo $row['balance']; ?> Beezes that you can exchange here.</span><br/>
<span class='heading'>Enter the amount you wish to redeem and hit submit.</span><br/>
<form class="btcregform" action='redeem.php' method='post'>
<input class="btcregforminput" type='text' value='' id='vidcoinamount' name='vidcoinamount'>
<input class="btcregformbutton" type='submit' value='Submit' id='button' name='redeembutton'>
</form>
<?php // If trying to redeem what the user don't have CLOSE
} else { ?>
<?php
// Redeem amount is OK OPEN
$walletID = get_wallet_id();
$date = date("Y-m-d H:i:s");
$ipadr = $_SERVER['REMOTE_ADDR'];
$iscomplete = 'No';
$deductamount = $actualBalance-$redeemedBalance;
// Get current BTC price from BlockChain into $btcprice (0,01 usd is virool payment per video)
$btcprice = 0.00004335;
// Multiply the redeemed balance with the amount in actual BTC worth 0,01 usd.
$valueInBTC = $btcprice * $btcprice;
// This gets rid of some formatting issues
$actualBTC = sprintf("%.10f",$valueInBTC);
$setBalance = " UPDATE users SET balance='$deductamount' WHERE username='$username' ";
$con = connect();
mysqli_query($con, $setBalance) or die ('Couldn\'t set balance to database !');
$setRequest = " INSERT INTO requests VALUES ('','$username','$walletID','$redeemedBalance','$actualBTC','$date','$ipadr','$iscomplete') ";
mysqli_query($con, $setRequest) or die ('Couldn\'t set payment request for admin into database !');
mysqli_close($con);
?>
<span class='greeting'>Thank you!</span><br/>
<span class='heading'>Your exchange request has been received.</span><br/>
<span class='heading'>Please give us up to 48 hours to process it. On weekends it may take longer...</span><br/>
<span class='heading'>You have <b><?php print get_balance(); ?></b> Beezes left in your account</span><br/>
<br>
<?php
$dollars = get_balance() / 100;
?>
<?php print get_balance(); ?> Beezes = $<?php print $dollars; ?><br>
<?php } //If redeem amount is OK CLOSE ?>
<?php } else { // If the user hasn't done anything yet OPEN ?>
<span class='greeting'>Redeem your Beezes</span><br/>
<span class='heading'>Enter the amount you wish to redeem and hit submit.</span><br/>
<form class="btcregform" action='redeem.php' method='post'>
<input class="btcregforminput" type='text' value='' id='vidcoinamount' name='vidcoinamount'><br><br>
<input class="btcregformbutton" type='submit' value='Submit' id='button' name='redeembutton'>
</form>
<?php } //If the user hasn't done anything yet CLOSE ?>
我的问题是那部分
if ($actualBalance < $redeemedBalance && $redeemedBalance < 499)
如果实际余额大于兑换余额,那么它的工作原理,但是如果兑换保险金额小于500的部分没有被执行,那么它的行为就像它甚至不存在一样。请帮忙(新手在这里)
答案 0 :(得分:-1)
说实话,我对问题有所了解,但也许这会有所帮助:
<?php
$balance = 1500;
$price = 500;
if ($balance >= $price) { echo "There You go...."; }
else { echo "Sorry, You cant..."; }
?>
编辑。