I have an item page which basically fetches data from the database using an ID in the URL (e.g. item.php?id=1). I want the user to be able to delete the item and be redirected to the homepage WITHOUT having the ability to go back to that page (you can go back to that page by pressing back on the browser), given that when that item is deleted, there's no data left so I'd be left with undefined index errors.
I'm using window.location.replace() to achieve this, but it doesn't work, it's still able to go back to that page because it's still present in the browser history. Here's my code:
<a href='?deleteid=$row[id]' class='btn btn-danger operations'>Delete Post</a>
if (isset($_GET['deleteid'])) {
$delete = $_GET['deleteid'];
$query = mysqli_query($con, "DELETE FROM item WHERE id = '$delete'");
echo "<script>
window.location.replace('domain.com/end/mobile/');
</script>";
}