我有一個問題 - 填寫完表單並單擊提交後,它發送我填寫的信息,但是當我刷新頁面時,信息會再次發送。我怎樣才能防止它?我的PHP代碼如下所示:如何防止刷新後發送表單?
<?php
function Form()
{
if (isset($_POST['submit']))
{
$to = "[email protected]";
$name = $_POST['name'];
$email = $_POST['email'];
$text = $_POST['text'];
$subject = $_POST['subject'];
if (isset($_POST['name']) && !empty($_POST['name']) &&
isset($_POST['email']) && !empty($_POST['email']) &&
isset($_POST['text']) && !empty($_POST['text']) &&
isset($_POST['subject']) && !empty($_POST['subject']) &&
mail($to, $name, $email, $text, $subject))
{
echo "<div class='success'>Message has been sent!</div>";
}
else
{
}
}
}
?>
所以,當一個人在填寫表單,應該不是他刷新頁面後重新發送信息。我怎樣才能做到這一點?
http://en.wikipedia.org/wiki/Post/Redirect/Get – CBroe