Page 1 of 1

can php control 2 web pages?

Posted: Sun Mar 06, 2011 8:44 pm
by rittle
Hi, I have a very general question. I have one web page that, when a user clicks on a button, should open a new window for a user to upload information in. I was hoping that both web pages could be open at the same time and when the information is submitted in the second page, the first page will be updated automatically and the second will be recleared for another submission. I was planning on using one php file that would share the information between the pages and update both of them (by refreshing both web pages and using AJAX calls in the javascript to the same php file that's doing the refreshing) The information being submitted needs a bit of processing before displaying it in the first window, and I think it would be easier to process it in php then js. Anyways, that's what I was hoping to do, but I can't really find anything to help out with this. (I'm pretty new to php.)
So I guess the question is, can php be used to update two web pages simultaneously? If I'm trying to do something impossible, I guess I'd rather stop before wasting too much more time on it.
Thanks in advance.

Re: can php control 2 web pages?

Posted: Sun Mar 06, 2011 10:58 pm
by greyhoundcode
Looked at from a different angle, Javascript running on both webpages could access the same cookie data and make calls to the same PHP script server-side.

Re: can php control 2 web pages?

Posted: Fri Mar 11, 2011 11:56 am
by rittle
thanks for your advice, but I've been trying to avoid cookies since people are so finicky about them.
I did figure out a very ugly and ineloquent way to handle it using an extra "state" variable in the session that runs different sections of the code in the php. The php has conditionals in the code that depend on the "state" value to run them, and the state's value is changed at the end of each conditional's sequence.
That allowed both webpages to run the same php file using ajax. Thankfully, it could work in my case, since what the web pages were doing was cyclic, although I know it couldn't be used in all cases.
Like I said, VERY ugly, but it works.