谢谢你们帮助我。我有另一个问题。在我之前的问题中,我询问了如何在表单提交后使文本框消息显示在页面顶部。感谢你们,我设法做到了。下一个问题是如何使这种情况发生至少 8 倍?
<?php
include('header1.php');
if(isset($_POST['submit']) && $_POST['submit']=='Submit'){
message=$_POST['message'];
$name=$_POST["name"];
echo "<center>";
echo "<div>" . $name . "<br />" . $message ."</div>";
echo "</center>";
if(isset($_POST['submit']) && isset($_POST['prevmsg']) && isset($_POST['prevname'])){
echo "<center>";
echo $_POST['prevname'];
echo "<br/>";
echo $_POST['prevmsg'];
echo "</center>";
}
?>
<html>
<head>
</head>
<body style="position:center">
<form method="POST" action="<?=$_SERVER["PHP_SELF"]?>">
<table>
<tr>
<th>
<label for="name">Name</label>
</th>
<td>
<input type="text" name="name" id="name">
</td>
</tr>
<input type="hidden" name="prevname" value="<?=$name?>"/>
<tr>
<th>
<label for="message">Message</label>
</th>
<td>
<textarea name="message" id="message"></textarea>
</td>
</tr>
<input type="hidden" name="prevmsg" value="<?=$message?>"/>
</table>
<input type="submit" name="submit" value="Submit"/>
</form>
</body>
</html>
<?php
} else {
?>
<html>
<head>
</head>
<body>
<form method="POST" action="<?=$_SERVER["PHP_SELF"]?>">
<table>
<tr>
<th>
<label for="name">Name</label>
</th>
<td>
<input type="text" name="name" id="name">
</td>
</tr>
<tr>
<th>
<label for="message">Message</label>
</th>
<td>
<textarea name="message" id="message"></textarea>
</td>
</tr>
</table>
<input type="submit" name="submit" value="Submit"/>
</form>
</body>
</html>
<?php }
include('inc/footer.php');
?>