由于v4到v5的迁移,PHP脚本不再工作


PHP script no longer works because of v.4 to v5 migration

最近我的web服务器从PHP v.4迁移到v.5.3。我知道,我知道,好久不见了:)

但是现在,当用户输入所需的数据时,我的许多脚本不显示结果。脚本如下:

<?php 
if ($ok) {
    if ($heightft == "" || $heightin == "" || $weight == "") {
        $error = "<br><FONT COLOR=#FF0000>One of the fields above was not completed.</FONT><br>";
    } else {
        $bmi = $weight * 703 / (($heightft * 12 + $heightin) * ($heightft * 12 + $heightin));
        $bmiString = number_format($bmi,2,".","");
        echo "<table border='1' cellpadding='10' bordercolor='0000FF'><tr><td><strong>Your BMI is: " . $bmiString;
echo "<br><br></strong>";
        if ($bmi <= 18.50) { 
            echo "You are classified as <strong>Underweight</strong>."; 
        } elseif ($bmi <= 24.99) {
            echo "You are classified as <strong>Normal</strong>."; 
        } elseif ($bmi <= 29.99) {
            echo "You are classified as <strong>Overweight</strong>."; 
        } else { 
            echo "You are classified as <strong>Obese</strong>.</td></tr></table></bordercolor>"; 
        }       
    }
}
?>
<?php echo $error;?>

看起来你在期待register_globals打开。现在默认是关闭的。

您应该根据表单方法使用$_GET['heightft']$_POST['heightft']来访问此数据。