简体   繁体   中英

Refresh one php page from another page

I have one PHP page(dashboard.php). on click on a button it opens up one pop up page(viewstatus.php).I updates some data on this page and click submit button on this page it updtes the data and close this popup and refresh the page dashboard.php.But my page dashboard.php is not refreshing. This is the code written on the file viewstatus.php.

$query->execute();

$_SESSION['msg']="Stationery Added successfully";
header("Refresh:0; url=dashboard.php");

echo "<script>window.close();</script>";

Try this please:

$query->execute();

$_SESSION['msg']="Stationery Added successfully";
header("Refresh:0; url=dashboard.php");

echo "<script>window.opener.location.reload();window.close();</script>";

The reason the page is not refreshing is because the header is redirecting the popup page, not the dashboard page.

Refreshing the page on demand is going to be pretty difficult. When you open the popup you can save that variable in javascript and add an onclose listener, but this is not supported in all browsers.

var popup = window.open('...');
if (popup) {
    popup.onclose = function(){ window.location.reload };
}

Another way would be in your popup window to add the following code:

window.opener.location.reload();

Just add that above the window.close(); that you put in your example code and it might work. It worked for me, but just as the other one I don't know if this is supported by all browsers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM