温度が 70 度以上になると結果ページが赤くなり、70 度を下回ると青くなるようなページを作成しようとしています。送信ページのコードの最初の部分のサンプル ページが既にあります。言葉が色を変えるのではなく、ページ全体が温度に基づいて色を変えるようにしたい. 誰でも助けることができますか?
<html>
<body>
<?php
if (isset($_POST['temperature'])): //isset determines if var has valid contents, even empty string
//if var is set, show what it contains
$myFahrenheit = (int)$_POST['temperature']; //cast value sent via post to an integer
$myCelsius = intval(($myFahrenheit-32) * (5/9)); //calc celsius
echo '<h1><font color="blue">You entered ' . $myFahrenheit . ' in Fahrenheit!!</font><br />';
echo '<h1><font color="red"> It is '. $myCelsius .' in celsius!!</font><br />';
//put link on page to reset form
print '<a href="' . $_SERVER['PHP_SELF'] . '">Reset page</a>';
else:
//show form
?>
<!--Note the server variable indicating the page we are on -->
<form action="<? print $_SERVER['PHP_SELF']; ?>" method="post">
Enter your temperature in Fahrenheit <input type="text" name="temperature"><br>
<input type="submit" value="Show me the temperature in celsius!!">
</form>
<?
endif;
?>
</body>
</html>