<html>
<body>
<form method="post" action=" echo $_SERVER['PHP_SELF'];">
名字:<input type="text" name="fname">
<input type="submit">
</form>
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// 收集输入字段的值
$name = $_POST['fname'];
if (empty($name)) {
echo "名字没有填写";
} else {
echo $name;
}
}
</body>
</html>