#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Location
    Netherlands
    Posts
    458
    Rep Power
    13

    javascript runs, even after I've redirected


    I have a recordet. In case that recordset doenst have any results I redirect the visitor like
    ---------------------------------------------------------------
    <?php
    if ($totalRows_getlanguage < 1)
    { header("Location: anotherpage.php"); }
    ?>


    All of this is coded above the <HTML> tag.

    I also have some javascript opening a new page in a new window in the <HEAD> part.

    However this javascript still opens the fullscreenpage, even if there are no result from the recordset, and thus ignoring somehow the redirection while he parent window get redirected to 'anotherpage.php'.

    Is there a way in PHP that when a redirection takes place, the rest of the code must be ignored?

    cheers
    Patrick



    Question
  2. #2

  3. Join Date
    Aug 2001
    Location
    NYC
    Posts
    57
    Rep Power
    14
    place exit; on the line after your header function (it's a good habit to get into this).
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Location
    Netherlands
    Posts
    458
    Rep Power
    13
    It doenst work:
    I've changed the code to
    ----------------------------------------------------------------------
    <?php
    // redirect to another page
    if ($totalRows_getlanguage < 1)
    { header("Location: another page.php");
    exit;
    }
    ?>

    I still get the javescript popup
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Location
    Netherlands
    Posts
    458
    Rep Power
    13
    Sorry............It DOES work, I had a redirection script also in the other page
    How stupid can someone be sometimes

    cheers
    Patrick

IMN logo majestic logo threadwatch logo seochat tools logo