我正在尝试创建一个页面,当输入温度为 70 或高于 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>