#1
  1. No Profile Picture
    Ulrik N
    Guest
    Devshed Newbie (0 - 499 posts)
    Hi there!

    If I'm in the middle of a script, and want's to load a new dokument. How do I do That?
    ex.
    .
    .
    .some code
    if ($var==true) {
    load("./new.html")
    }
    .
    .some other code



    ------------------
    regds..
    -ulrik-

  2. #2
  3. No Profile Picture
    jpenix
    Guest
    Devshed Newbie (0 - 499 posts)
    You'd send a HTML redirect header using PHP's header() function, but it can only be done before any output goes to the screen.

    So you can check some conditions at the top of your script (but don't print/echo anything), and then send the appropriate header() command to move the user to the correct page.
  4. #3
  5. No Profile Picture
    TheHawk
    Guest
    Devshed Newbie (0 - 499 posts)
    You could use:
    if ($var == true){
    include("/path_to_file/filename.txt");
    }
  6. #4
  7. No Profile Picture
    Ulrik N
    Guest
    Devshed Newbie (0 - 499 posts)
    I know of these two methods, but I'm in the middle of a html dokument, then I escape the html code and do some stuff...
    If $var returns true I have to load a "clean" dokument, not related to the one I'm working in....

    ------------------
    regds..
    -ulrik-

  8. #5
  9. No Profile Picture
    jpenix
    Guest
    Devshed Newbie (0 - 499 posts)
    To the best of my knowledge, once that page is on its way to your browser, that's it. You have no more control...

    Maybe there's something you can do in JavaScript...

    I don't see why you can't put the PHP that "does some stuff" up top before you start outputting to the browser... just rearrange your page code.

    Then there's always PHP4 with output buffering that gives you some more control over this stuff... but even with that, when you flush the buffer to the browser, that's it. You have no control to change anything...
  10. #6
  11. No Profile Picture
    SepodatiCreations
    Guest
    Devshed Newbie (0 - 499 posts)
    You can use javascript. the following will load up a new page when it is encountered:
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    location.href="new_page.htm"
    [/quote]
    If you are within some PHP code, you'd have to get out and process (or echo) this javascript commands within some <script> tags. This example might be kind of long, but I know it works. you can adjust it as need be.
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    <?php
    if ($var == true) {
    ?>
    <script language="javascript">
    location.href="new_page.htm";
    </script>
    <?php
    }
    ?>
    [/quote]

Similar Threads

  1. Automatical generation of Word document
    By walliscw in forum Visual Basic Programming
    Replies: 6
    Last Post: February 6th, 2004, 07:17 AM
  2. Why won't an image load multiple times on same page?
    By funkyville in forum Web Design Help
    Replies: 1
    Last Post: October 21st, 2003, 09:29 AM
  3. how to load data into the textbox array?
    By hamster84 in forum Visual Basic Programming
    Replies: 3
    Last Post: September 19th, 2003, 12:46 AM
  4. Advanced XSL questions
    By neobuddah in forum XML Programming
    Replies: 5
    Last Post: September 16th, 2003, 01:49 PM
  5. Page not load
    By GDH in forum PHP Development
    Replies: 0
    Last Post: August 28th, 2003, 01:02 PM

IMN logo majestic logo threadwatch logo seochat tools logo