By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,695 Members | 1,601 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,695 IT Pros & Developers. It's quick & easy.

Open a new url in main window with PHP

P: n/a
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
Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
NC
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

Jul 17 '05 #2

P: n/a

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

Jul 17 '05 #3

P: n/a
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:11**********************@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

Jul 17 '05 #4

P: n/a
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');

Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.