php写个4位数的测试评分dome 需要页面样式
<p>以下是一个简单的PHP代码示例,用于创建一个4位数的测试评分系统,并附带基本的HTML和CSS样式:</p>
<p>HTML代码:</p>
<!DOCTYPE html>
<html>
<head>
<title>4位数测试评分系统</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h1>4位数测试评分系统</h1>
<form action="score.php" method="post">
<label>请输入您的得分:</label>
<input type="text" 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="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 (preg_match('/^[0-9]{4}$/', $score)) {
echo '您的得分是:' . $score;
} else {
echo '请输入一个4位数的得分!';
}
}
?>
原文地址: http://www.cveoy.top/t/topic/OGa 著作权归作者所有。请勿转载和采集!