For Programmers: Free Programming Magazines  


Home > Archive > PHP Programming > April 2005 > Open a new url in main window with PHP









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Open a new url in main window with PHP
Henk

2005-04-25, 8:55 pm

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


NC

2005-04-26, 3:57 am

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

micha

2005-04-26, 8:57 am


NC wrote:
> Henk wrote:
> ...
>
> 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

Henk

2005-04-26, 8:56 pm

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.googlegroups.com...
> Henk wrote:
> ...
>
> 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
>



hackajar@gmail.com

2005-04-27, 3:56 am

This type of request usually is for annoying pop-up banners. If this
REALLY is for login, use something like this:

if (!session_is_registered('count')) require_once('login.php');

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com