當按下按鈕:
<form action="index.php" method="get">
<input type="hidden" name="act" value="run">
<input type="submit" value="Truncate map">
</form>
if (!empty($_GET['act'])) {
mysql_query("TRUNCATE TABLE mapinfo");
}
它重定向我index.php?act=run
我想擺脫它,所以說:header("Refresh: 0; url=$page");
:
if (!empty($_GET['act'])) {
mysql_query("TRUNCATE TABLE mapinfo");
$page = $_SERVER['PHP_SELF'];
header("Refresh: 0; url=$page");
}
但它第一次加載index.php?act=run
不是重定向瀏覽器index.php
這使得2頁刷新。
如何做到這一點的好方法?
您需要顯示錶單本身的代碼。 – Duniyadnd
根據您的要求添加表格代碼。 –
讓用戶僅僅使用GET請求就可以清除表格,這是一個非常糟糕的主意。僅處理數據會更好。 – Alex