Any way to use header() or another function to force user to "top level"

This is a discussion on Any way to use header() or another function to force user to "top level" within the PHP General forums, part of the PHP Programming Forums category; I have some code doing some checks that sit inside div tags using href elements: .... <div class="pArea&...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-13-2008
Chuck
 
Posts: n/a
Default Any way to use header() or another function to force user to "top level"

I have some code doing some checks that sit inside div tags using href elements:
....
<div class="pArea">
<a class="panel" href="code.php?xxxx=yyyy" target="pframe1" >Panel1</a>
....

In code.php, if various conditions aren't met, this script will do a
bunch of house cleaning, logging, then redirect using
header("Location: /some_url").

My problem is that /some_url comes up inside the div area, instead of
causing the browser to load /some_url as if accessed directly. Im
just starting to dabble with PHP so I'm sure there is another way of
doing this or maybe an argument to header() itself.

I'm looking for the same behavior as the HTML snippet <a href="/"
target="_top">here</a>

Once I make the call to header(), I no longer care about any state
information, session variables, or anything. Basically I am booting
the user out of the application and back to the login/splash page. All
information I need to retain has already been logged to various
mechanisms prior to calling header() which is immediately followed by
exit();

Thanks for any help,
CC
Reply With Quote
  #2 (permalink)  
Old 01-13-2008
Jim Lucas
 
Posts: n/a
Default Re: [PHP] Any way to use header() or another function to force userto "top level"

Chuck wrote:
> I have some code doing some checks that sit inside div tags using href elements:
> ...
> <div class="pArea">
> <a class="panel" href="code.php?xxxx=yyyy" target="pframe1" >Panel1</a>
> ...
>
> In code.php, if various conditions aren't met, this script will do a
> bunch of house cleaning, logging, then redirect using
> header("Location: /some_url").
>
> My problem is that /some_url comes up inside the div area, instead of
> causing the browser to load /some_url as if accessed directly. Im
> just starting to dabble with PHP so I'm sure there is another way of
> doing this or maybe an argument to header() itself.
>
> I'm looking for the same behavior as the HTML snippet <a href="/"
> target="_top">here</a>
>
> Once I make the call to header(), I no longer care about any state
> information, session variables, or anything. Basically I am booting
> the user out of the application and back to the login/splash page. All
> information I need to retain has already been logged to various
> mechanisms prior to calling header() which is immediately followed by
> exit();
>
> Thanks for any help,
> CC
>


Sounds like header() is what you are looking for then.

The one thing that you have to make sure is that you have not sent any
data to the browser. Use this:

<?php

#
#Do whatever you want here. Just don't output any data to the browser.
#

header('Location: http://www.example.com/');
exit;
# Always follow a header/location redirect with the "exit;" command.

?>

I have found that it is best to include the entire domain when using the
header/location redirect method.
Reply With Quote
  #3 (permalink)  
Old 01-13-2008
Chuck
 
Posts: n/a
Default Re: [PHP] Any way to use header() or another function to force user to "top level"

That is exactly what I am using now but the location I am redirecting
to is loading within the <div> tags and at the top level of the
browser.

-CC
On 1/12/08, Jim Lucas <lists@cmsws.com> wrote:
> Chuck wrote:
> > I have some code doing some checks that sit inside div tags using href elements:
> > ...
> > <div class="pArea">
> > <a class="panel" href="code.php?xxxx=yyyy" target="pframe1" >Panel1</a>
> > ...
> >
> > In code.php, if various conditions aren't met, this script will do a
> > bunch of house cleaning, logging, then redirect using
> > header("Location: /some_url").
> >
> > My problem is that /some_url comes up inside the div area, instead of
> > causing the browser to load /some_url as if accessed directly. Im
> > just starting to dabble with PHP so I'm sure there is another way of
> > doing this or maybe an argument to header() itself.
> >
> > I'm looking for the same behavior as the HTML snippet <a href="/"
> > target="_top">here</a>
> >
> > Once I make the call to header(), I no longer care about any state
> > information, session variables, or anything. Basically I am booting
> > the user out of the application and back to the login/splash page. All
> > information I need to retain has already been logged to various
> > mechanisms prior to calling header() which is immediately followed by
> > exit();
> >
> > Thanks for any help,
> > CC
> >

>
> Sounds like header() is what you are looking for then.
>
> The one thing that you have to make sure is that you have not sent any
> data to the browser. Use this:
>
> <?php
>
> #
> #Do whatever you want here. Just don't output any data to the browser.
> #
>
> header('Location: http://www.example.com/');
> exit;
> # Always follow a header/location redirect with the "exit;" command.
>
> ?>
>
> I have found that it is best to include the entire domain when using the
> header/location redirect method.
>
>



--
Chuck Carson - Sr. Software Engineer
Galileo Educational Solutions
Reply With Quote
  #4 (permalink)  
Old 01-13-2008
Jim Lucas
 
Posts: n/a
Default Re: [PHP] Any way to use header() or another function to force userto "top level"

Chuck wrote:
> That is exactly what I am using now but the location I am redirecting
> to is loading within the <div> tags and at the top level of the
> browser.
>
> -CC
> On 1/12/08, Jim Lucas <lists@cmsws.com> wrote:
>> Chuck wrote:
>>> I have some code doing some checks that sit inside div tags using href elements:
>>> ...
>>> <div class="pArea">
>>> <a class="panel" href="code.php?xxxx=yyyy" target="pframe1" >Panel1</a>


Wait, looking at your link again I see that you are directing the
loading of this page request to a frame call "pframe1". If you are
trying to redirect the iframe with the header() call, then no, their is
no way to do what you are trying to do with the header() function. You
will need to do this client side with javascript. something like this
would do the job.

window.parent.location = '/';

I think that is the syntax. If not, it is a good start.

>>> ...
>>>
>>> In code.php, if various conditions aren't met, this script will do a
>>> bunch of house cleaning, logging, then redirect using
>>> header("Location: /some_url").
>>>
>>> My problem is that /some_url comes up inside the div area, instead of
>>> causing the browser to load /some_url as if accessed directly. Im
>>> just starting to dabble with PHP so I'm sure there is another way of
>>> doing this or maybe an argument to header() itself.
>>>
>>> I'm looking for the same behavior as the HTML snippet <a href="/"
>>> target="_top">here</a>
>>>
>>> Once I make the call to header(), I no longer care about any state
>>> information, session variables, or anything. Basically I am booting
>>> the user out of the application and back to the login/splash page. All
>>> information I need to retain has already been logged to various
>>> mechanisms prior to calling header() which is immediately followed by
>>> exit();
>>>
>>> Thanks for any help,
>>> CC
>>>

>> Sounds like header() is what you are looking for then.
>>
>> The one thing that you have to make sure is that you have not sent any
>> data to the browser. Use this:
>>
>> <?php
>>
>> #
>> #Do whatever you want here. Just don't output any data to the browser.
>> #
>>
>> header('Location: http://www.example.com/');
>> exit;
>> # Always follow a header/location redirect with the "exit;" command.
>>
>> ?>
>>
>> I have found that it is best to include the entire domain when using the
>> header/location redirect method.
>>
>>

>
>

Reply With Quote
  #5 (permalink)  
Old 01-13-2008
Anup Shukla
 
Posts: n/a
Default Re: [PHP] Any way to use header() or another function to force userto "top level"

Chuck wrote:
> That is exactly what I am using now but the location I am redirecting
> to is loading within the <div> tags and at the top level of the
> browser.
>


Are you using AJAX to load the page?

--
Regards,
Anup Shukla
Reply With Quote
  #6 (permalink)  
Old 01-13-2008
AlmostBob
 
Posts: n/a
Default Re: [PHP] Any way to use header() or another function to force user to "top level"

<a class="panel" href="code.php?xxxx=yyyy" target="_top" >Panel1</a>

in javascript after the load
<script LANGUAGE="javascript" TYPE="text/javascript" >
<!--
if (top != self)
top.location.replace(self.location);
-->
</script>

--
If at first you dont succeed
try try try again
If at first you do succeed
try not to look surprised

_
"Chuck" <chuck.carson@gmail.com> wrote in message
news:3be30bc50801122206g92271bau772b9538e6ce8731@m ail.gmail.com...
> That is exactly what I am using now but the location I am redirecting
> to is loading within the <div> tags and at the top level of the
> browser.
>
> -CC
> On 1/12/08, Jim Lucas <lists@cmsws.com> wrote:
> > Chuck wrote:
> > > I have some code doing some checks that sit inside div tags using href

elements:
> > > ...
> > > <div class="pArea">
> > > <a class="panel" href="code.php?xxxx=yyyy" target="pframe1"

>Panel1</a>
> > > ...
> > >
> > > In code.php, if various conditions aren't met, this script will do a
> > > bunch of house cleaning, logging, then redirect using
> > > header("Location: /some_url").
> > >
> > > My problem is that /some_url comes up inside the div area, instead of
> > > causing the browser to load /some_url as if accessed directly. Im
> > > just starting to dabble with PHP so I'm sure there is another way of
> > > doing this or maybe an argument to header() itself.
> > >
> > > I'm looking for the same behavior as the HTML snippet <a href="/"
> > > target="_top">here</a>
> > >
> > > Once I make the call to header(), I no longer care about any state
> > > information, session variables, or anything. Basically I am booting
> > > the user out of the application and back to the login/splash page. All
> > > information I need to retain has already been logged to various
> > > mechanisms prior to calling header() which is immediately followed by
> > > exit();
> > >
> > > Thanks for any help,
> > > CC
> > >

> >
> > Sounds like header() is what you are looking for then.
> >
> > The one thing that you have to make sure is that you have not sent any
> > data to the browser. Use this:
> >
> > <?php
> >
> > #
> > #Do whatever you want here. Just don't output any data to the browser.
> > #
> >
> > header('Location: http://www.example.com/');
> > exit;
> > # Always follow a header/location redirect with the "exit;" command.
> >
> > ?>
> >
> > I have found that it is best to include the entire domain when using the
> > header/location redirect method.
> >
> >

>
>
> --
> Chuck Carson - Sr. Software Engineer
> Galileo Educational Solutions



Reply With Quote
  #7 (permalink)  
Old 01-14-2008
Richard Lynch
 
Posts: n/a
Default Re: [PHP] Any way to use header() or another function to forceuser to "top level"

On Sat, January 12, 2008 9:42 pm, Chuck wrote:
> I have some code doing some checks that sit inside div tags using href
> elements:
> ...
> <div class="pArea">
> <a class="panel" href="code.php?xxxx=yyyy" target="pframe1"
> >Panel1</a>

> ...
>
> In code.php, if various conditions aren't met, this script will do a
> bunch of house cleaning, logging, then redirect using
> header("Location: /some_url").
>
> My problem is that /some_url comes up inside the div area, instead of
> causing the browser to load /some_url as if accessed directly. Im
> just starting to dabble with PHP so I'm sure there is another way of
> doing this or maybe an argument to header() itself.
>
> I'm looking for the same behavior as the HTML snippet <a href="/"
> target="_top">here</a>
>
> Once I make the call to header(), I no longer care about any state
> information, session variables, or anything. Basically I am booting
> the user out of the application and back to the login/splash page. All
> information I need to retain has already been logged to various
> mechanisms prior to calling header() which is immediately followed by
> exit();


I don't think a DIV tag can do what you want...

Perhaps you should do your validation checks in the script that writes
the DIV tag instead, and bounce the user from there, which would be
trivial.

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:35 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0