PHP update window? equivalent to reloading the F5 page?

Is there anything in PHP that is equivalent to manually clicking the F5 page reload button? My php script is in the frame and is not a parent script, but it needs to refresh the whole page, not just its frame.

+8
php refresh reload
source share
10 answers

With PHP you can just handle server-side stuff. What you can do is print this in your iframe:

parent.window.location.reload(); 
+6
source share

This is actually possible:

 Header('Location: '.$_SERVER['PHP_SELF']); Exit(); //optional 

And it will reload the same page.

+24
source share

If you have text before

 header('Location: http://www.example.com/youformhere.php'); 

you’ll have problems because they must be sent before any other text is sent to the page.

Try using this code instead

 <?php $page = $_SERVER['PHP_SELF']; echo '<meta http-equiv="Refresh" content="0;' . $page . '">'; ?> 

Just remember that this code will also create an infinite loop, so you may have to make some conditional changes.

+5
source share

PHP cannot force the client to do anything. He cannot refresh the page, not to mention updating the frame's parent.

EDIT: You can, of course, make PHP write JavaScript, but it is not PHP, it is actually JavaScript, and it will not work if JavaScript is disabled.

 <?php echo '<script>parent.window.location.reload(true);</script>'; ?> 
+4
source share
 <?php echo "<script>window.opener.location.reload();</script>"; echo "<script>window.close();</script>"; ?> 
+1
source share

with php you can use two redirects. It works the same way as updating in some issues.

you can use the redirect.php page and post your last url using the GET method (for example). then in redirect.php you can change the title to the location that you sent it to it with the GET method.

like this: your page:

 <?php header("location:redirec.php?ref=".$your_url); ?> 

redirect.php:

 <?php $ref_url=$_GET["ref"]; header("location:redirec.php?ref=".$ref_url); ?> 

which worked for me well.

+1
source share

Use JavaScript for this. You can do:

 echo ' <script type="text/javascript"> parent.window.location.reload(true); </script> '; 

In PHP and update the parent page of the frame.

0
source share

Guess that you can repeat the meta tag to do the update at regular intervals ... for example

 <meta http-equiv="refresh" content="600" url="your-url-here"> 
0
source share

All you need to do to manually refresh the page is to provide a link pointing to the same page

Like this: Refresh selection

0
source share

Adding the following to the page title works for me:

 <?php if($i_wanna_reload_the_full_page_on_top == "yes") { $reloadneeded = "1"; } else { $reloadneeded = "0"; } if($reloadneeded > 0) { ?> <script type="text/javascript"> top.window.location='indexframes.php'; </script> <?php }else{} ?> 
-one
source share

All Articles