晚上好
我想问一下这个问题。我正在尝试编写一个程序,当我点击转移时,它将从余额中扣除金额并使用mysql数据库中的新余额进行更新。
我的代码看起来像这样
修改
$myotp = $_POST['otp'];
if(OTPPASS==$myotp)
{
$amt = $POST['amt'];
require 'config/config.php';
$con = mysqli_connect($hostname, $user, $pass, $db) or die ('Cannot connect');
$sql = "select openBal from accInfo where userID ='".$_SESSION['userID']."'";
$result = mysqli_query($con,$sql);
$row = mysqli_fetch_array($result);
$balance = $row['openBal'];
$account = $row['accountNo'];
$sql2 = "update accInfo set openBal='".$balance."'-$amt here accountNo='".$account."'";
mysqli_query($con,$sql2);
echo "Transfer Complete";
mysqli_close($con);
header('Location: success.html');
}else{
echo ("<SCRIPT LANGUAGE='JavaScript'>
window.alert('Transaction Failed')
window.location.href='transfers.php';
</SCRIPT>");
}
?>
问题是它没有从数据库行中扣除余额,$row['openBal']
我需要对此进行进一步解释,寻找互联网并找不到好文章。
我开始考虑可能是我设置sql
文件的方式..