You are invited to Log in or Register a free Frihost Account!

php page refresh

Is it possible to refresh a page without using header("Location: XXXX");?
I would like something like a forced mouseclick on a link, kind of like header works but something that doesn't interfer with session_start(); the way headers do.
Simply, no. I've been looking for this myself and I couldn't find anything.

Sorry, I might be wrong though, and if I am i'd quite like to hear what could be used.
PHP is server side scripting. If a user presses a button you cant lift the event with php (unless you make a link or a form submit).
I dont really know if I understood what you need, but if you need to "refresh" a site with a click, thats easy: you put a link to the same site (or an action="site" if its a form submit).

But what I think is more suitable is that you use jaascript. you can use something like:
<input type=button value="Refresh" onClick="history.go()">

<a href="javascript:location.reload(true)">Refresh page</a>

If you don't want to wait for user input just use
<body onLoad="javascript:location.reload(true)">

or just put a timer..

If you could please be more specific about what you want.
The reason I want some kind of page refresh is this:
I have a site where users loggin, which makes the $_Session[] array fill
with there username when they logg out I destroy the session by doing
a unset() and a destroy() just to be sure. I then don't want someone to be able to gain entrence to the member pages by pushing the backbutton. There for I check if the superglobal array is empty or not this works on all memberpages exept for nylank.php. the relevant parts of the pages are presented below.

Any thought on what could be wrong? Oh, and if I use the back button to gain access to nylank.php and then refresh the page inloggcheck.php kicks in like I want to, but I want to do that instantly.

Hope all of this made any sense to someone Wink

the file nylank.php:

include 'inloggcheck.php';

$b="alternate ";

include 'inloggcheck.php';

the file inloggcheck.php:

if($_SESSION['inloggaduser']== "")
echo "<html><head><title>Davem Lingu</title>";
echo "<link rel='stylesheet' type='text/css' href='davlin.css' title='davlin'/>";
echo "</head><body><div id='container'><div id='header'><h1>Lab2 - PHP och MYSQL</h1><h2>Link archive</h2></div><div id='navigation'>";
echo "<ul><li><a href='start.php'> STARTSIDA </a></li><li><a href='links.php'> Länkar </a></li>";
echo "<li><a href='nyanvandare.php'> Registrera </a></li></ul></div><div id='content'>";
echo "<b>Du är inte inloggad och har därför inte tillgång till denna sida</b> <br> Om du har ett konto klicka på STARTSIDA och logga sedan in,";
echo "<br> om inte klicka på registrera och skapa en användare och logga <br> därefter in för att få tillgång till medlemssidorna.<br><br>";
echo "</div><div id='footer'><p>&copy; 2007 <a href=''>DavLin</a></p></div></div></body></html>";
dawiid wrote:
kind of like header works but something that doesn't interfer with session_start(); the way headers do.
What do you mean?

I've never had any interference from header() to the session_start() or the other way around.
You cannot do what you want -- not reliably anyway.

You can try messing with the cache functions of your webserver/script.

Best thing to do is to pass the responsibility of clearing the cache to the user. When the user logs out, tell them to clear the cache for security.
OK, thx for the answers! Smile Guess I've to accept there is no quick fix here. I have got to check the header and session for the 100:th time and see what I have missed, somewhere there is probably an output before the session or something like that or some little ' or " that I've missed. Thx again, keep up the good work!
header("Location: $location");

works fine for me Confused
RT Cunningham
phpinfo() is your friend. Just don't let anyone else see it.

Sessions can be tricky if you don't know what's happening behind the scenes. If session cookies are turned off, but trans sid is enabled, you still have to code the header like trans sid is disabled.
RT Cunningham
Oops, forgot to mention that ob_start and ob_flush will take of headers sent before the header call.
you should place ob_start(); at the beginning, and ob_end_flush(); at the end of the page Smile at least, that is the way i'm using Smile
RT Cunningham
The only difference between ob_flush and ob_end_flush is that ob_end_flush destroys the buffer and the other does not. If it's before a header call, it doesn't matter because the buffer will self-destruct. Smile
Related topics
PB PHP, Iframe and Javascript
PHP Counter
php page-refresh/redirect/boot help needed please
Never Mind Problem Resolved
live chart / graphic in php pages
PHP Page
Creating a page with php
help - download pop up on php page
PHP Image Questions
how do i make a window/iframe in a table within php page..??
php page flickering, maybe caused by flash item
PHP page turning problem
PHP Whos Online Code OR Page refresh..
How to make a php page act differently
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

© 2005-2011 Frihost, forums powered by phpBB.