How to refresh browser from PHP code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
crandym
Forum Newbie
Posts: 21
Joined: Thu Jan 29, 2004 8:52 am

How to refresh browser from PHP code

Post by crandym »

What is the best way to refresh the browser screen through PHP.

Problem: Have an image displayed on a page and use file menu to pick a new file. The file replaces the existing filem but the filename remains the same. Next time I visit this page, the old image (cached) appears with the new image width/height size. I would like to force a refresh of the browser from within PHP. Any ideas?

Thanx

crandym
Straterra
Forum Regular
Posts: 527
Joined: Mon Nov 24, 2003 8:46 am
Location: Indianapolis, Indiana
Contact:

Post by Straterra »

header("Location : blabla.php");
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

PHP can't refresh a page, say every 5 seconds, or whatever. To do that you're gonna need to use Javascript. However, it sounds like what you've got is just a caching problem. Putting these three meta tags in my files has stopped caching on any pages I've used.

<meta http-equiv="Cache-Control" Content="no-cache">
<meta http-equiv="Pragma" Content="no-cache">
<meta http-equiv="Expires" Content="0">
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
crandym
Forum Newbie
Posts: 21
Joined: Thu Jan 29, 2004 8:52 am

Post by crandym »

I've reviewed several forum topics on several websites on this particular topic. I'll be more specfic about this issue.

1. Application I am debugging is a single php page which contains a duel function - if called by itself (i.e., story.php), provide list of times that can be edited, if called with values (i.e., story.php?story=22) activites an html editing screen with a submit button. The submit button calls another file story_submit.php which update the database and then does a "header('Location: '.$HTTP_POST_VARS['destination']);" which goes back to story.php page.

If on the data editing portion of this page, you use html "<td align="center"><input type="file" name="picture" size="40"></td>" to load a new image which works fine. When you submit, the data is stored correctly in the database and directory. But when you go to edit the data again, the old image appears with the new images size. PHP code is looking at the new image file and creating the w/h footprint, but the actual image is the old image coming from cache (i.e., because the filenames are the same).

All I'm looking for is a simply way to trigger the Browsers refresh function 1 time.
Straterra
Forum Regular
Posts: 527
Joined: Mon Nov 24, 2003 8:46 am
Location: Indianapolis, Indiana
Contact:

Post by Straterra »

This is a caching problem. You need to use the META tags mentioned above to make sure the person doesn't cache the pictures.
Post Reply