<html>
<body>
<form method="post" action=" echo $_SERVER['PHP_SELF'];">
名字:<input type="text" name="fname">
<input type="submit">
</form>
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// collect value of input field
$name = htmlspecialchars($_REQUEST['fname']);
if (empty($name)) {
echo "Name is empty";
} else {
echo $name;
}
}
</body>
</html>