我有3個PHP頁面,第一個是我有一個表單,用戶可以輸入他的帳戶(電子郵件地址)和他想從他的帳戶中扣除的金額。 第二我有功能和成功消息顯示的調用。 在第三頁上,函數send()完成,它打開數據庫連接,更改帳戶的金額並保存。成功頁面的PHP重新加載(F5)將再次調用數據庫更新
第一頁:
<form action="send_exec.php" method="post">
Amount: <input type="number" size="24" maxlength="4"
name="points_send" min="0"><br><br>
Account<input type="text" size="24" maxlength="50"
name="email"><br><br>
<input type="submit" value="Send">
</form>
第二頁(send_exec.php):
<?php
include("update_send.php");
$email = $_POST["email"];
$points_send = $_POST["points_send"];
settype ($points_send, "integer");
send($email, $points_send);
echo ("Success");
?>
第三頁(update_send.php):
//some calculations are done before this to get $new_points
function send($email, $points_send)
{
$mysql_update_points = "UPDATE user SET points = ('$new_ponints') WHERE email = ('$email')";
$mysql_update = mysql_query($mysql_update_points);
}
問題是現在,當我在第一頁上執行操作,然後結束第二頁:如何在我的瀏覽器中單擊F5/reload時禁用該操作行動被再次調用?
與其他人一樣:將瀏覽器移至其他頁面。 –
最簡單的方法是將瀏覽器重定向到成功的其他頁面;移動'echo(「Success」);'到一個新的頁面/腳本(我們將其命名爲'success.php')並將其替換爲'header('Location:/success.php');'in'send_exec.php' 。 – axiac
參見例如https://en.wikipedia.org/wiki/Post/Redirect/Get – VolkerK