创建了一个表单,它在提交按钮上发出警报,其中包含三个条件
1)付款方式是银行,金额超过900000
2)付款方式为现金,金额超过20000
我的金额是用逗号和小数点转换数字(。)
我的问题是条件剂量显示有条件的警报。 如果我在检查第二个条件时抛出警报框而不仅仅是第一个条件。
帮我解决这个问题。
这是我的PHP代码
if(isset($_POST['Reset']))
{
$re_id=$_POST['rec_id'];
$re_no=$_POST['rec_no'];
//$re_date=$_POST['rec_date'];
$re_date = date('d-m-Y', strtotime($_POST['rec_date']));
$re_acc=$_POST['rec_acc'];
$re_pay=$_POST['rec_pay'];
//$re_amount=$_POST['rec_amount'];
$re_amount = number_format($_POST['rec_amount'], 2, '.', ',');
$query="UPDATE tbl_reciept SET rec_no='$re_no', rec_date='$re_date', rec_acc='$re_acc', rec_pay_type='$re_pay', rec_amount='$re_amount' WHERE rec_id='$re_id'";
if($re_pay=="Cash" && $re_amount>=20000)
{
mysqli_query($dbcon,$query);
echo "<script>
alert('amount is grater than 20000');
window.location.href='../reciept.php';
</script>";
}
else if($re_pay=="Bank" && $re_amount>= 900000)
{
mysqli_query($dbcon,$query);
echo "<script>
alert('amount is grater than 900000');
window.location.href='../reciept.php';
</script>";
}
else
{
mysqli_query($dbcon,$query);
header('Location: ../reciept.php');
}
}
答案 0 :(得分:0)
This will work...
echo "<script>
alert('amount is grater than 900000');
window.location.href='http://stackoverflow.com/questions';
</script>";
Note: Pass full path other wise case Bellow case
window.location.protocol = "http:"
window.location.host = "www.test.com"
window.location.pathname = "example/index.html"