refreshing the page using php

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
User avatar
sakaveli
Forum Commoner
Posts: 60
Joined: Tue Apr 06, 2004 9:42 am

refreshing the page using php

Post by sakaveli »

hi,

my website is using Flash headers which point to php pages, the only problem is that once the browser has loaded the pages once, it doesnt load them again, so any changes do not show up unless the page is refreshed. if i change my internet settings to "refresh on every visit to a page" then my website works fine.

ive tried using meta tags but i dont think im using them right, all pages are being displayed through my index.php which is below:

Code: Select all

<?php
 	include("header.php");
	if ($page == "") {
		$page = "main";
	}
	echo "<meta http-equiv='refresh' content='0;URL=index.php'>"; 
	include("pages/".$page.".php");
	include("footer.php");
	mysql_close($db);	
?>
but that doesnt work, any ideas??
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

As long as you place it at the top of the page before anything is sent to the user you can use:

Code: Select all

header('Location: http://www.google.com');
And if not, you can always use javascript:

Code: Select all

window.location='http://www.google.com';
User avatar
sakaveli
Forum Commoner
Posts: 60
Joined: Tue Apr 06, 2004 9:42 am

Post by sakaveli »

thanks for the reply,
what does that code actually achieve? it looks like its redirecting to google?

i need my page to refresh everytime i click on a link, any idea?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

You are using 'refresh' in the cache sense, not the redirecting sense which i think is causing the confusion.
Look at http://php.net/header , it has examples of forcing a page not to be cached, i think that's what you're after.
dipit
Forum Newbie
Posts: 12
Joined: Thu Apr 08, 2004 2:36 am
Location: india
Contact:

hi

Post by dipit »

i think it will help u

<?php

// refresh / redirect to an internal web page
// ------------------------------------------
header( 'refresh: 5; url=/webdsn/' );
echo '<h1>You will be re-directed in 5 seconds...</h1>';


// refresh / redirect to an internal web page
// ------------------------------------------
header( 'refresh: 3; url=/' ); # redirects to our homepage
echo '<h1>You will be re-directed in 3 seconds...</h1>';


// refresh / redirect to an external web page
// ------------------------------------------
header( 'refresh: 0; url=http://www.example.net' );
echo '<h1>You won''t know what hit you!</h1>';
?>
_________________
let's work in a group.
Post Reply