NYCPHP Meetup

NYPHP.org

[nycphp-talk] Forcing page refresh

Chris Shiflett shiflett at php.net
Thu Aug 7 11:32:15 EDT 2003


--- crisscott at netzero.com wrote:
> I am trying to figure out if it is possible to force a page refresh
> for all users viewing a page at the same time.

Not exactly, but you can have pages that represent states in a state machine.

1. Regular page - has a Refresh header to refresh itself every 30 seconds
2. New Page - has a Refresh header to refresh itself every 30 seconds

When you want everyone to see the new page, you change the URL in the Refresh
header in state 1 to point to state 2.

I'm sure there are better examples of a state machine, but that just came to
mind. Keep in mind that this is not completely reliable and that you're
generating a lot of unnecessary traffic (and load) on your Web server to do
something that seems very unimportant.

> I want all users to see a new page when one user submits info via a form.

Can you explain what you're trying to do? Surely there is a better path to
take.

>  I am picturing something along the lines of:
> 
> if(submit)
> {
>    write_to_file($POST[new info]);
>    foreach($ip_addr in $ip_addr_207.18.113.234?list)
>    {
>      fsockopen($ip);
>      fputs(headers to refresh page);
>      fclose();
>    }
> }
> else
> {
>    echo read_from_file();
> }
> 
> My question is, can I send headers to an ip address and expect the web
> browser to refresh even though the user at that address hasn't done
> anything?

Nope. Imagine how awful that would be. Web browsers are HTTP clients, not
servers.

Hope that helps.

Chris

=====
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/



More information about the talk mailing list