当我按提交时,它会返回成功消息,但不会扣除在线时间或增加信用额度。我做错了什么? 我对PHP很陌生,所以如果你发现任何错误,请指出它。
谢谢!
<?
include ("config.php");
$link = mssql_connect($server, $user, $pass);
if(!$link) {
die('Unavailable');
} else {
$rate1 = 20;
$rate2 = 20;
$rate3 = 20;
$rate4 = 50;
$onResult = mssql_query("SELECT MinutosOnline from MuOnline.dbo.MEMB_STAT where memb___id='test'");
$online = mssql_fetch_row($onResult);
if ($online[0] % 60 != 0) {
$hour = number_format(($online[0] / 60), 0);
$minutes = $online[0] % 60;
} else {
$hour = number_format(($online[0] / 60), 0);
$minutes = 0;
};
if (isset($_GET['coinAdd'])) {
$convertCoin = $_GET['convert'];
$addType = 'WCoinP';
$r = $online[0] - ($convertCoin * 60);
if ($addType == 'WCoinC') {
$addCoin = $convertCoin * $rate1;
} elseif ($addType = 'WCoinP') {
$addCoin = $convertCoin * $rate2;
} elseif ($addType = 'goblin') {
$addCoin = $convertCoin * $rate3;
} else {
$addCoin = $convertCoin * $rate4;
}
if ($convertCoin > $hour)
{
echo 'Amount to exchange cannot be greater than your available hour.';
}
else {
$deduct = mssql_query("UPDATE MuOnline.dbo.MEMB_STAT SET MinutosOnline=(MinutosOnline - ".$r.") WHERE memb___id='test'");
$add = mssql_query("UPDATE MuOnline.dbo.T_InGameShop_Point SET ".$addType."=(".$addType." + ".$addCoin.") WHERE accountid='test'");
if ($deduct && $add) {
echo 'Success';
} else {
echo 'Error';
}
}
}
echo '
<form id="sign_up_frm" method="GET">
<fieldset><legend>Exchange</legend>
<div class="required">
<label>Online Time: </label> '.$hour.' hour '.$minutes.' minutes.
</div>
<div class="required">
<label>Currency: </label> Online hour -> Coins or Credit
</div>
<table class="sct_table" cellspacing="0">
<tr class="hd">
<td>Amoount</td>
<td>WCoinC</td>
<td>WCoinP</td>
<td>GoblinCoin</td>
<td>Credit</td>
</tr>
<tr>
<td>1 hour</td>
<td>'.$rate1.'</td>
<td>'.$rate2.'</td>
<td>'.$rate3.'</td>
<td>'.$rate4.'</td>
</tr>
</table>
<div class="required">
<label for="confirm_password">Exchange:</label>
<input type="text" name="convert" class="inputText" size="12" maxlength="100" value="" placeholder="enter the amount" /><input type="hidden" name="coinAdd"/>
<small>Enter the amount of hour you want to exchange.</small>
</div>
</fieldset>
<fieldset>
<div class="submit">
<div>
<input type="submit" class="inputSubmit" value="Cancel" />
<input type="submit" class="inputSubmit" value="Submit" />
</div>
</div>
</fieldset>
</form>
';
}
mssql_close($link);
?>