This repository has been archived on 2025-01-09. You can view files and clone it, but cannot push or open issues or pull requests.
Files
luowei_exam/bmi_631_1.php
2025-01-09 11:57:41 +08:00

36 lines
1.0 KiB
PHP

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$height = $_POST['height'];
$weight = $_POST['weight'];
if ($height!= "" && $weight!= "") {
$bmi = $weight / ($height * $height);
if ($bmi >= 18.50 && $bmi <= 23.90) {
$result = "BMI指数正常";
} else {
$result = "BMI指数异常";
}
} else {
$result = "请输入完整的身高和体重信息";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>BMI健康指标计算器</title>
</head>
<body>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
身高(米): <input type="text" id="height" name="height" placeholder="请输入身高"><br>
体重(千克): <input type="text" id="weight" name="weight" placeholder="请输入体重"><br>
<input type="submit" id="ok" name="ok" value="确定">
</form>
<?php if (isset($result)) {?>
<p><?php echo $result;?></p>
<?php }?>
</body>
</html>