我正确地获得了'GET'所需的号码。我已将的值分配给变量。但是,当比较“>”或“ <”时,会产生荒谬的结果。我无法得到正确的结果。
<?php // SEPETE ÜRÜN EKLEME ***************************
session_start();
ob_start();
if(isset($_GET['urunKodu'])){
$eldeki_stok = $_GET['stock'];
$istenen_miktar = $_GET['amount'];
if($istenen_miktar < $eldeki_stok){ **// This section does not work correctly.**
echo '<script language="javascript">';
echo 'alert("transaction accepted !")';
echo '</script>';
…
header("Refresh: 0; url=http://www.xxxxxxxxxx.com/xxxx.php");
}elseif($eldeki_stok < $istenen_miktar){ **// This section does not work correctly.**
echo '<script language="javascript">';
echo 'alert("invalid operation")';
echo '</script>';
}
}else{
exit();
}
?>
答案 0 :(得分:-1)
我认为问题是您使用了if
和else
,但值数据类型除外
<?php
// SEPETE ÜRÜN EKLEME ***************************
session_start();
ob_start();
if (isset($_GET['urunKodu'])) {
$eldeki_stok = intval($_GET['stock']);
$istenen_miktar = intval($_GET['amount']);
if ($istenen_miktar < $eldeki_stok) { // This section does not work correctly.**
echo '<script language="javascript">';
echo 'alert("transaction accepted !")';
echo '</script>';
…
header("Refresh: 0; url=http://www.xxxxxxxxxx.com/xxxx.php");
} else { // This section does not work correctly.**
echo '<script language="javascript">';
echo 'alert("invalid operation")';
echo '</script>';
}
} else {
exit();
}
?>
当值相同时,初始方法不能满足情况