Reputation: 2146
Hello I am using following code to open a page in PHP
header('Location :login.php');
but the problem is that this is doing inside the div of page, when I clicking on that the page is being loaded inside the DIV not on the fill screen, what should I write here to solve the problem?
edit
I am loading the page like this
javascript, in main.php
var div = document.getElementById('content');
var url = 'my.php';
div.innerHTML = '<iframe style="width:100%;height:100%;" frameborder="0" src="' + url + '" />';
and I give a link to logout in my.php, here I need to open a login page and destroy the main.php page
Upvotes: 1
Views: 1553
Reputation: 8682
Instead of returning a redirect (which redirects only your frame) like you do now, you'll have to have the top frame redirected.
Since your code gets loaded in an IFRAME
, you'll need to change the TOP frame position, instead or returning a header, return the following javascript:
<script type="text/javascript">
window.top.location = "http://www.example.com/path/login.php";
</script>
The trick is to use window.top
instead of window
.
Upvotes: 1
Reputation: 539
You are displaying stuff before header is sent.
if ( !headers_sent() ) {
header("Location: login.php");
} else {
echo '<meta http-equiv="refresh" content="0;url=login.php">';
}
Javascript redirect.
<script type="text/javascript">
window.location = "http://www.domain.com/login.php";
</script>
Upvotes: 1