-
-
Save cloneko/7450721 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function bmi ($height,$mass){ | |
return $mass / pow($height/100,2); | |
} | |
function h($str) { | |
return htmlspecialchars($str, ENT_QUOTES, "UTF-8"); | |
} | |
?> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<style> | |
#over{ | |
color: red; | |
display: inline; | |
} | |
#slim{ | |
color: blue; | |
display: inline; | |
} | |
#standard{ | |
color: black; | |
display: inline; | |
} | |
</style> | |
</head> | |
<body> | |
<?php | |
if (isset($_POST["submit"])) { | |
$bmi = bmi($_POST["height"], $_POST["mass"]); | |
$bmi = round($bmi, 1); | |
print "あなたの BMI 値は" . h($bmi) . "です "; | |
} else { | |
print "BMI 値を計算します "; | |
} | |
?> | |
<form action="<?php print($_SERVER['REQUEST_URI']); ?>" method="POST"> | |
身長 <br> | |
<input type="text" name="height"><br> | |
体重 <br> | |
<input type="text" name="mass"><br> | |
<input type="submit" name="submit" value=" 送信 "><br> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment