【发布时间】:2017-03-26 14:45:02
【问题描述】:
我正在尝试在提交表单后关闭窗口并刷新主页,然后在 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加载。
提前致谢
【问题讨论】:
-
你实现
action=enabled了吗? -
请发布完整代码
-
我的回答在您的请求末尾添加了
action=enabled。您的代码未处理action=enabled -
好的,非常感谢。我将如何让我的代码处理该请求?
标签: javascript php url