现在我遇到一个问题,用户会看到弹出窗口“更新成功”,如果他重新加载页面或向后到页面。任何人知道如何删除?id = 2后点击确定弹出?
这是我的代码:
update_action.php
$updresult = mysqli_query($conn, $sqlu);
if (!$updresult)
echo "Unable to update record". mysqli_error($conn);
else
{
header('Location: index.php?id=2' );
mysqli_close($conn);
}
?>
的index.php
if ($id == 1)
{
?>
<script>
alert("Invalid user name or password, Try again");
</script>
<?php
}
else if($error_id == 2)
{
?>
<script>
alert("Update Sucessfully!");
</script>
<?php
}
答案 0 :(得分:1)
if ($id == 1)
{
?>
<script>
alert("Invalid user name or password, Try again");
</script>
<?php
}
else if($error_id == 2)
{
?>
<script>
alert("Update Sucessfully!");
//---------- added ---------------
window.location.href= 'index.php';
//-------------------------
</script>
<?php
}
答案 1 :(得分:0)
您需要的是使用javascript更改网址而不重新加载网页。
退房:https://wiki.selfhtml.org/wiki/JavaScript/History/pushState
您可以在提醒/确认后将其放入
// Remove the "?.." from the url
var url = [location.protocol, '//', location.host, location.pathname].join('');
// maybe check if the browser supports history.pushState
history.pushState({}, '', url);