【发布时间】:2011-07-17 00:26:55
【问题描述】:
例如下面的文件是 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 数据并且事情得到弄乱。谁能想到更好的办法?
【问题讨论】:
-
有时候页面不刷新是什么原因?