Page to open only in Frameset

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rajkpy
    New Member
    • May 2009
    • 3

    Page to open only in Frameset

    Hi Expert,
    Please help. Please look at the code below for 'include.php', which is included in every php file of my application
    //Include.php
    Code:
    <?php
    session_start();
    if(!session_is_registered("SESSION")){
    $home_url = 'http://'. $_SERVER['HTTP_HOST'].'/admin_dev/authentication/login.php';
    header('Location: ' . $home_url);
    exit();
    }
    else
    $timeout_url = 'http://'.$_SERVER['HTTP_HOST'].'/admin_dev/authentication/timeout.php';
    header( "refresh: 120; url=$timeout_url");
    $home_url2= 'http://'. $_SERVER['HTTP_HOST'].'/admin_dev/authentication/frame.php';
    //echo "<script>if (parent.frames.length<1) location.replace($home_url2)</script>";
    ?>
    Actually when I uncomment the 'echo' statement i am getting " header cannot be modified error....', and when I comment it things are working fine.
    I hope the page in which it is included also tries to send something in header, but since 'echo' statement has already sent the header, I am getting this error.
    My problem is, I want to open all those pages in which include.php is included, in a frameset and not as individual pages.
    Please let me know how can I implement this.
    Note: I can't touch the files in which it is included but only this file for certain reasons.

    Thanks
    Last edited by Markus; May 8 '09, 05:40 PM. Reason: Added [code] tags.
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    It's a little foggy on why you're using frames, but checkout PHP's ob_start() (ob stands for output buffer)

    If you call that function at the top of your script, php won't send any data back to the browser until it is done processing (or ob_flush() is called)

    Reason your getting the error is because you can't modify the header() after the content is already sent.

    I hope that helps you find your way,


    Dan

    Comment

    Working...