优化bug!DOCTYPE htmlhtmlhead title4位数测试评分系统title link rel=stylesheet href=stylecssheadbody div class=container h14位数测试评分系统h1 form action=scorephp method=post label请输入您的得分:label input type=text nam
<p>优化后的代码:</p>
<!DOCTYPE html>
<html>
<head>
<title>4位数测试评分系统</title>
<meta charset="utf-8">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h1>4位数测试评分系统</h1>
<form action="score.php" method="post">
<label>请输入您的得分:</label>
<input type="number" name="score" maxlength="4" required>
<input type="submit" value="提交">
</form>
</div>
</body>
</html>
<p>CSS代码:</p>
<p>.container {
margin: 50px auto;
width: 500px;
text-align: center;
}</p>
<p>h1 {
font-size: 36px;
margin-bottom: 30px;
}</p>
<p>form label {
font-size: 24px;
}</p>
<p>form input {
font-size: 24px;
padding: 10px;
margin: 10px;
border-radius: 5px;
border: none;
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.2);
}</p>
<p>form input[type="number"] {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}</p>
<p>form input[type="submit"] {
background-color: #4CAF50;
color: white;
cursor: pointer;
}</p>
<p>form input[type="submit"]:hover {
background-color: #3e8e41;
}</p>
<p>PHP代码:</p>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$score = $_POST['score'];
if (strlen($score) == 4) {
echo '您的得分是:' . $score;
} else {
echo '请输入一个4位数的得分!';
}
}
?>
原文地址: https://www.cveoy.top/t/topic/OGw 著作权归作者所有。请勿转载和采集!