This is a discussion on Open a new url in main window with PHP within the PHP Language forums, part of the PHP Programming Forums category; I'm looking for a way in PHP to reroute the main window. If during the build of a page ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I'm looking for a way in PHP to reroute the main window.
If during the build of a page in a child frame some conditions are not met, I would like to reload a login page in the main window, and not in the child frame. header("location: http:.........................."); When I use the above method the page is rerouted in the child frame. Is there a method in clean PHP that can open this page in the main window, a little bit like in javascript: if (parent) parent.location.href = "login.php"; Note: using javascript on the client side is not an option I think. Thanks a lot, Henk |
|
|||
|
Henk wrote:
> > I'm looking for a way in PHP to reroute the main window. > If during the build of a page in a child frame some conditions > are not met, I would like to reload a login page in the main > window, and not in the child frame. .... > Note: using javascript on the client side is not an option I think. Your best bet is to move processing of conditions out of frames into the frameset. The frameset should check the conditions and then, depending on the outcome, either redurect to the login page or render the frameset. Failing that, you can still process in frames, but display an error message in a way that would ensure proper redirection. For example: echo <<<MSG <p>Authorization failed. <br> Click <b>OK</b> to return to the login page. </p> <form action="login.php" target=_top> <input type="submit" value="OK"> </form> MSG; Cheers, NC |
|
|||
|
NC wrote: > Henk wrote: > > > > I'm looking for a way in PHP to reroute the main window. > > If during the build of a page in a child frame some conditions > > are not met, I would like to reload a login page in the main > > window, and not in the child frame. > ... > > Note: using javascript on the client side is not an option I think. > > Your best bet is to move processing of conditions out of frames > into the frameset. The frameset should check the conditions and > then, depending on the outcome, either redurect to the login page > or render the frameset. > > Failing that, you can still process in frames, but display an > error message in a way that would ensure proper redirection. > For example: > > echo <<<MSG > <p>Authorization failed. <br> > Click <b>OK</b> to return to the login page. </p> > <form action="login.php" target=_top> > <input type="submit" value="OK"> > </form> > MSG; > > Cheers, > NC yes, to make that clear: php runs server side, so it has no way of knowing (and accessing) frames in the browser. micha |
|
|||
|
Yes, your last example could be I nice solution.
I need this when a user is logged out and then uses the back button or the links in the history list again. I noticed the no-cache code in the PHP tutorial is sometimes not working, for example when users are given less rights in the browser's settings by the system administrator. When the server then notices an unauthorized user is requesting for a page, it would indeed be appropriate to send this user a clear message that he is not authorized, instead of a silent redirect to the login page. Thanks, Henk "NC" <nc@iname.com> schreef in bericht news:1114473261.666802.317690@z14g2000cwz.googlegr oups.com... > Henk wrote: >> >> I'm looking for a way in PHP to reroute the main window. >> If during the build of a page in a child frame some conditions >> are not met, I would like to reload a login page in the main >> window, and not in the child frame. > ... >> Note: using javascript on the client side is not an option I think. > > Your best bet is to move processing of conditions out of frames > into the frameset. The frameset should check the conditions and > then, depending on the outcome, either redurect to the login page > or render the frameset. > > Failing that, you can still process in frames, but display an > error message in a way that would ensure proper redirection. > For example: > > echo <<<MSG > <p>Authorization failed. <br> > Click <b>OK</b> to return to the login page. </p> > <form action="login.php" target=_top> > <input type="submit" value="OK"> > </form> > MSG; > > Cheers, > NC > |