例如以下文件是SamePage.php
<!DOCTYPE html>
<html lang="en">
<head><title>Personal Information</title></head>
<body>
<?php
if(!empty($_POST))
{
echo $_POST['var'].'<br />';
//do a bunch of stuff
...
echo "Inserted into database succesfully! You will now be redirected.<meta http-equiv=refresh content=4;url=database.php><br /></body></html>";//meta refresh gets rid of old POST data
exit;
}
?>
Add another entery:<br />
<form method="POST" action="SamePage.php"><--!It sends the information to itself-->
name: <input type="text" name="name" size="10" maxlength="25" /><br />
telephone: <input type="text" name="telephone" size="10" maxlength="25" /><br />
birthday: <input type="text" name="birthday" size="10" maxlength="25" /><br />
<input type="submit" value="add" />
<input type="reset" value="clear" />
</form>
</body>
</html>
在那里退出并不是很好,有时我不想刷新页面,但必须完成包装用户按下浏览器上的刷新并再次发送相同的POST数据弄乱。谁能想到更好的方法?
答案 0 :(得分:0)
最好是将表单发送到另一个页面并重新加载页面......但如果您不想要,可以: