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@xxxxxxxxx> 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
.



Relevant Pages

  • Re: Setting up a page that will intercept all pages that do not already exist?
    ... >Using the ErrorDocument 404 syntax to redirect everything not found to ... >a PHP script will issue a 404 header to the browser, ... >the header is followed by html. ... REDIRECT_* variables if the error document is a CGI or PHP script; ...
    (comp.lang.php)
  • Re: How can I stop this error occurring pls?
    ... The reason for the errors is that you're trying to send a header to redirect ... the user *after* you've already sent output to the browser. ... This turns output buffering on which means ...
    (comp.lang.php)
  • Re: [PHP] Any way to use header() or another function to force user to "top level"
    ... to is loading within the <div> tags and at the top level of 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 headerfunction. ... causing the browser to load /some_url as if accessed directly. ...
    (php.general)
  • Re: [PHP] Any way to use header() or another function to force user to "top level"
    ... just starting to dabble with PHP so I'm sure there is another way of ... Once I make the call to header(), I no longer care about any state ... The one thing that you have to make sure is that you have not sent any data to the browser. ... I have found that it is best to include the entire domain when using the header/location redirect method. ...
    (php.general)
  • Re: More header fixed
    ... the common solution is a table of column headers, following by a div with overflow:auto, then render a table in the div. ... your second sample did not work with my browser, so its probably not cross browser compatible. ... I have an HTML table with a header. ...
    (microsoft.public.dotnet.framework.aspnet)

Loading