954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to 'refresh' a php page?

how do you get a php page to refresh or reload?
start right from the top again?

thanks in advance from sunny clearwater fl.

cheesywan
Newbie Poster
3 posts since Oct 2004
Reputation Points: 10
Solved Threads: 0
 

To refresh or reload php page, you can use "Meta"
e.g

It will refresh in every 3 seconds. You can change 3 to number you like.

PoA
Posting Whiz in Training
237 posts since Jul 2004
Reputation Points: 26
Solved Threads: 9
 

or without url

fatihpiristine
Posting Whiz in Training
283 posts since Sep 2007
Reputation Points: 6
Solved Threads: 19
 

Cant you just do a javascript refresh?

jbennet
Moderator
Moderator
18,523 posts since Apr 2005
Reputation Points: 1,826
Solved Threads: 601
 
fatihpiristine
Posting Whiz in Training
283 posts since Sep 2007
Reputation Points: 6
Solved Threads: 19
 

I dont like every time the page refresh. I want the page will be reloaded only once. can u help me to do that?

Rajivgandhi
Newbie Poster
6 posts since Nov 2009
Reputation Points: 10
Solved Threads: 0
 

try this

header("Cache-Control: no-cache");

everytime the page is requested, a fresh copy is loaded. Is this what u r lookin for?I dont like every time the page refresh. I want the page will be reloaded only once. can u help me to do that?

venkat0904
Junior Poster
190 posts since Oct 2009
Reputation Points: 13
Solved Threads: 21
 

I am using php to get an image from database. when I get an image, the image will be shown after hitting the refresh button. pls help me to solve this

Rajivgandhi
Newbie Poster
6 posts since Nov 2009
Reputation Points: 10
Solved Threads: 0
 

That must be because ur browser has a cache copy of the page...
browsers use this mechanism to enhance the surfing speed...
add this on top of ur page-

header(“Pragma: no-cache”);
header(“cache-Control: no-cache, must-revalidate”); // HTTP/1.1
header(“Expires: Mon, 26 Jul 1997 05:00:00 GMT”); // Date in the past

This will instruct browser not to maintain the cache copy of this specific page.. and hopefully u wont need to hit refresh to display ur image...
Cheers!!I am using php to get an image from database. when I get an image, the image will be shown after hitting the refresh button. pls help me to solve this

venkat0904
Junior Poster
190 posts since Oct 2009
Reputation Points: 13
Solved Threads: 21
 

Still its not working. The above code shown in output window. can u give me the full code to insert and retrieve image from the database by using blob.

Rajivgandhi
Newbie Poster
6 posts since Nov 2009
Reputation Points: 10
Solved Threads: 0
 
Still its not working. The above code shown in output window. can u give me the full code to insert and retrieve image from the database by using blob.

its getting displayed in browser !!! Are you sure u placed these lines inside <?php tag??
Why dont u post up the code u r using and i shall suggest what modifications are required..

venkat0904
Junior Poster
190 posts since Oct 2009
Reputation Points: 13
Solved Threads: 21
 

Have messed this up b4
If the nocache code is getting displayed in the browser in the output window
Assuming the page displayed is "page.php"
page.php includes the line <img src="getImageFromDatabase.php" alt='database blob image'> or something similar
The nocache code previously listed should be inserted in the of "page.php" not "getImageFromDatabase.php" else that code is output to the browser as well as (or instead of) the image
the nocache code should work

almostbob
Posting Sensei
3,149 posts since Jan 2009
Reputation Points: 571
Solved Threads: 376
 
Have messed this up b4 If the nocache code is getting displayed in the browser in the output window Assuming the page displayed is "page.php" page.php includes the line <img src="getImageFromDatabase.php" alt='database blob image'> or something similar The nocache code previously listed should be inserted in the of "page.php" not "getImageFromDatabase.php" else that code is output to the browser as well as (or instead of) the image the nocache code should work

hey almostbob,
correct me if m wrong but the header function is supposed to execute before displaying any output in the browser isnt it? then how are u supposed to place it inside head tag.
I believe it must go on the top of page which is used to display the image ie which outputs html for image display... watsay?
what you are trying to tell is the use of meta tag inside head which is also an option but doesnt works with IE. so the best way is to use http headers...

venkat0904
Junior Poster
190 posts since Oct 2009
Reputation Points: 13
Solved Threads: 21
 

for me it is 3am
corrected text should read
The nocache code previously listed should be inserted in "page.php" not "getImageFromDatabase.php" else that code is output to the browser

almostbob
Posting Sensei
3,149 posts since Jan 2009
Reputation Points: 571
Solved Threads: 376
 

I want to upload audio and video into the database.. Is it possible? If possible, then tell me how to do that?

Rajivgandhi
Newbie Poster
6 posts since Nov 2009
Reputation Points: 10
Solved Threads: 0
 

To ensure an image is reloaded, send a unique URL.

eg:

image.php?random-number123

Where random_number123 can be generated by:

<?php

$random = microtime(true);

// eg

echo '<img src="image.php?'.$random.'" />';

?>
digital-ether
Nearly a Posting Virtuoso
Moderator
1,293 posts since Sep 2005
Reputation Points: 461
Solved Threads: 101
 

just use: <?php header("Location: #"); ?>

for example:

<?php

if (true) {

header("Location: #");

} else {
// nothing happens
}

?>

or, make a text link:

<a href="#">click this link</a>

"#" is often used to redirect people to the top of a page, but it will actually refresh the page as wel.

Greetings,

JasperWestra
Newbie Poster
1 post since Nov 2009
Reputation Points: 10
Solved Threads: 0
 

if(isset($_SESSION['reloaded'])){
//DO NOTHING
}
else{
$_SESSION['reloaded']=true;
header ("Location: yourpage.domain");
}

whatnowvv
Newbie Poster
1 post since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

Hie guyz! Have you tried

header( 'refresh: 2; url=/location/' );

where

refresh - tells the page to refresh
,
2 - tells the page to refresh in 2sec
and
url=/location/ - is the location of the page being refreshed.

U will notice that itz the same as redirecting but just to the same page.


For redirecting:

header( 'url=/location/' );

tinashezharare
Newbie Poster
1 post since Dec 2010
Reputation Points: 10
Solved Threads: 0
 


Just press F5.

lyrico
Junior Poster in Training
94 posts since Dec 2010
Reputation Points: 33
Solved Threads: 15
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You