I am using following code for a refreshing page, it is not reloading on completion. The following code is not working sometime.
$page = $_SERVER['PHP_SELF']; $sec = "10"; header("Refresh: $sec; url=$page"); echo "Watch the page reload itself in 10 second!";
PHP is server-side language, so you can not refresh the page with PHP, but JavaScript is the best option to refresh the page: location. reload();
Approach 1: One can auto refresh the webpage using the meta tag within the head element of your HTML using the http-equiv property. It is an inbuilt property with HTML 5. One can further add the time period of the refresh using the content attribute within the Meta tag.
The easiest way to reload the current page without losing form data, use WebStorage where you have -persistent storage (localStorage) or session-based (sessionStorage) which remains in memory until your web browser is closed. window. onload = function() { var name = localStorage.
Use a <meta>
redirect instead of a header redirect, like so:
<?php $page = $_SERVER['PHP_SELF']; $sec = "10"; ?> <html> <head> <meta http-equiv="refresh" content="<?php echo $sec?>;URL='<?php echo $page?>'"> </head> <body> <?php echo "Watch the page reload itself in 10 second!"; ?> </body> </html>
you can use
<meta http-equiv="refresh" content="10" >
just add it between the head tags
where 10 is the time your page will refresh itself
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With