我想在表單提交後關閉一個窗口,並刷新主頁面,然後在URL內傳遞信息以執行操作彈出窗口。刷新舊頁面,同時關閉當前頁面,並在url中添加一個動作
我有代碼工作正常,但似乎無法通過信息。
這裏是工作的代碼
echo "<script>window.close();window.opener.location.reload(true);</script>";
我曾嘗試以下,我知道它錯了,但不知道從哪裏尋求答案也不太清楚該怎麼尋找
<?php
// include database connection
$id=isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
// include database connection
include '../../../assets/connect.php';
try {
// get record ID
// isset() is a PHP function used to verify if a value is there or not
// delete query
$query = "DELETE FROM investment_return Where id = '$id'";
$stmt = $con->prepare($query);
$stmt->bindParam(1, $id);
if($stmt->execute()){
// redirect to read records page and
// tell the user record was deleted
echo "<script>window.close();window.location.href = window.location.href + '?action=entered';</script>";
}else{
die('Unable to delete record.');
}
}
// show error
catch(PDOException $exception){
die('ERROR: ' . $exception->getMessage());
}
?>
由於你可以告訴我試圖在網址的末尾添加?action=entered
。
上面的代碼關閉了窗口,但沒有添加所需的信息到最後,現在不需要刷新,因爲它將會是一個新的url加載。
提前
你實現'行動= enabled'? –
是的,我有,我確定我錯過了一些非常基本的東西 – thenashone
請發佈整個代碼 –