|
|
| (Eine dazwischenliegende Version desselben Benutzers wird nicht angezeigt) |
| Zeile 2: |
Zeile 2: |
| Der Body-Mass-Index (BMI) – auch Körpermasseindex (KMI), Körpermassenzahl (KMZ) oder Quetelet-Kaup-Index – ist eine Maßzahl für die Klassifizierung des Körpergewichts eines Menschen in Relation zu seiner Körpergröße. Sie wurde 1832 von Adolphe Quetelet sowie nach dem Ersten Weltkrieg von Ignaz Kaup entwickelt. Der BMI ist lediglich eine grob schätzende Maßzahl, da sie weder Statur und biologisches Geschlecht noch die individuelle Zusammensetzung der Körpermasse aus Fett- und Muskelgewebe eines Menschen berücksichtigt. | | Der Body-Mass-Index (BMI) – auch Körpermasseindex (KMI), Körpermassenzahl (KMZ) oder Quetelet-Kaup-Index – ist eine Maßzahl für die Klassifizierung des Körpergewichts eines Menschen in Relation zu seiner Körpergröße. Sie wurde 1832 von Adolphe Quetelet sowie nach dem Ersten Weltkrieg von Ignaz Kaup entwickelt. Der BMI ist lediglich eine grob schätzende Maßzahl, da sie weder Statur und biologisches Geschlecht noch die individuelle Zusammensetzung der Körpermasse aus Fett- und Muskelgewebe eines Menschen berücksichtigt. |
|
| |
|
| <iframe> | | <iframe |
| <?php
| | src="https://lexcalcbackend.medxam.de/calculator/bmi.php" |
| function toFloat($v): ?float {
| | width="100%" |
| if ($v === null) return null;
| | height="600" |
| $v = trim((string)$v);
| | style="border:0;" |
| if ($v === '') return null;
| | sandbox="allow-scripts allow-same-origin"> |
| $v = str_replace(',', '.', $v);
| |
| if (!is_numeric($v)) return null;
| |
| return (float)$v;
| |
| }
| |
| | |
| $weight = toFloat($_POST['weight'] ?? null); // kg
| |
| $height = toFloat($_POST['height'] ?? null); // cm
| |
| $bmi = toFloat($_POST['bmi'] ?? null);
| |
| | |
| $result = "";
| |
| $error = "";
| |
| | |
| if ($_SERVER['REQUEST_METHOD'] === 'POST') {
| |
| $filled = 0; | |
| foreach ([$weight, $height, $bmi] as $x) if ($x !== null) $filled++;
| |
| | |
| if ($filled < 2) {
| |
| $error = "Bitte mindestens zwei Felder ausfüllen.";
| |
| } else {
| |
| // Validations (only for provided fields)
| |
| if ($weight !== null && ($weight <= 0 || $weight > 600)) $error = "Gewicht wirkt ungültig.";
| |
| if ($height !== null && ($height <= 0 || $height > 300)) $error = "Größe wirkt ungültig.";
| |
| if ($bmi !== null && ($bmi <= 0 || $bmi > 150)) $error = "BMI wirkt ungültig.";
| |
| | |
| if ($error === "") {
| |
| // Determine which one to calculate: prefer empty one, if all 3 filled -> recompute BMI from weight+height
| |
| if ($weight === null && $height !== null && $bmi !== null) {
| |
| $h_m = $height / 100.0;
| |
| $weight = $bmi * ($h_m ** 2);
| |
| $result = "Gewicht berechnet.";
| |
| } elseif ($height === null && $weight !== null && $bmi !== null) {
| |
| $h_m = sqrt($weight / $bmi);
| |
| $height = $h_m * 100.0;
| |
| $result = "Größe berechnet.";
| |
| } else {
| |
| // BMI berechnen (wenn BMI leer ODER alle 3 ausgefüllt)
| |
| if ($weight === null || $height === null) {
| |
| $error = "Für BMI-Berechnung bitte Gewicht und Größe angeben.";
| |
| } else {
| |
| $h_m = $height / 100.0;
| |
| $bmi = $weight / ($h_m ** 2);
| |
| $result = "BMI berechnet.";
| |
| }
| |
| }
| |
| }
| |
| } | |
| }
| |
| | |
| function fmt($v, $dec=2) {
| |
| if ($v === null) return "";
| |
| return number_format($v, $dec, ',', ''); | |
| }
| |
| ?>
| |
| <!doctype html>
| |
| <html lang="de">
| |
| <head>
| |
| <meta charset="utf-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | |
| <title>BMI Rechner</title>
| |
| <style>
| |
| body { font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; margin: 32px; }
| |
| .wrap { max-width: 520px; }
| |
| label { display:block; margin: 12px 0 6px; font-weight: 600; }
| |
| input { width: 100%; padding: 10px 12px; font-size: 16px; }
| |
| .row { display:flex; gap: 12px; }
| |
| .row > div { flex: 1; }
| |
| button { margin-top: 16px; padding: 10px 14px; font-size: 16px; cursor: pointer; }
| |
| .msg { margin-top: 14px; padding: 10px 12px; border-radius: 8px; }
| |
| .ok { background: #eef9f0; }
| |
| .err { background: #fdecec; }
| |
| .hint { color:#555; margin-top: 8px; font-size: 14px; }
| |
| </style>
| |
| </head>
| |
| <body>
| |
| <div class="wrap">
| |
| <h2>BMI Rechner</h2>
| |
| <form method="post">
| |
| <label for="weight">Gewicht (kg)</label>
| |
| <input id="weight" name="weight" inputmode="decimal" placeholder="z. B. 82,5" value="<?= htmlspecialchars(fmt($weight, 1)) ?>">
| |
| | |
| <label for="height">Größe (cm)</label>
| |
| <input id="height" name="height" inputmode="decimal" placeholder="z. B. 182" value="<?= htmlspecialchars(fmt($height, 1)) ?>">
| |
| | |
| <label for="bmi">BMI</label>
| |
| <input id="bmi" name="bmi" inputmode="decimal" placeholder="z. B. 24,9" value="<?= htmlspecialchars(fmt($bmi, 2)) ?>">
| |
| | |
| <button type="submit">Berechnen</button>
| |
| | |
| <div class="hint">Fülle <b>zwei</b> Felder aus – das dritte wird berechnet. (Komma oder Punkt möglich.)</div>
| |
| </form>
| |
| | |
| <?php if ($error): ?>
| |
| <div class="msg err"><?= htmlspecialchars($error) ?></div>
| |
| <?php elseif ($result): ?>
| |
| <div class="msg ok">
| |
| <?= htmlspecialchars($result) ?><br>
| |
| <b>Gewicht:</b> <?= htmlspecialchars(fmt($weight, 1)) ?> kg<br>
| |
| <b>Größe:</b> <?= htmlspecialchars(fmt($height, 1)) ?> cm<br>
| |
| <b>BMI:</b> <?= htmlspecialchars(fmt($bmi, 2)) ?>
| |
| </div>
| |
| <?php endif; ?>
| |
| </div>
| |
| </body>
| |
| </html>
| |
| </iframe> | | </iframe> |