Redirection Help Emergency

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • RX

    #1

    Redirection Help Emergency

    I try to use PHP to redirect to other page and failed. Please give me a
    help. Thanks.

    The script is:

    if($rows_num>0)
    {
    session_start() ;
    session_registe r("userid");
    session_registe r("username") ;
    session_registe r("userpriv") ;
    $userid=$data[0]['user_id'];
    $username=$data[0]['username'];
    $userpriv=$data[0]['priv_id'];
    echo "<script
    language=javasc ript>self.locat ion='admin_cpan el.php';</script>";
    exit;
    }
    else
    {
    echo "<script
    language=javasc ript>self.locat ion='admin_logi n.php';</script>";
    exit;
    }

    The result is a blank page. No redirection as expected.



  • Daniel Tryba

    #2
    Re: Redirection Help Emergency

    RX <liqiangx@telus .net> wrote:[color=blue]
    > I try to use PHP to redirect to other page and failed. Please give me a
    > help. Thanks.[/color]

    No you are not, you are using javascript instead.
    [color=blue]
    >echo "<script language=javasc ript>self.locat ion='admin_cpan el.php';</script>";[/color]


    Read up on your javascript skills (eg:
    http://www.comptechdoc.org/independe...alocation.html)

    Better yet: use PHP:
    header("Locatio n: $abs_url");

    See http://php.net/header

    --

    Daniel Tryba

    Comment

    • Mike Discenza

      #3
      Re: Redirection Help Emergency

      RX wrote:
      [color=blue]
      > I try to use PHP to redirect to other page and failed. Please give me a
      > help. Thanks.
      >
      > The script is:
      >
      > if($rows_num>0)
      > {
      > session_start() ;
      > session_registe r("userid");
      > session_registe r("username") ;
      > session_registe r("userpriv") ;
      > $userid=$data[0]['user_id'];
      > $username=$data[0]['username'];
      > $userpriv=$data[0]['priv_id'];
      > echo "<script
      > language=javasc ript>self.locat ion='admin_cpan el.php';</script>";
      > exit;
      > }
      > else
      > {
      > echo "<script
      > language=javasc ript>self.locat ion='admin_logi n.php';</script>";
      > exit;
      > }
      >
      > The result is a blank page. No redirection as expected.[/color]

      try window.location ='http://www.mysite.com/admin_login.php '

      It looks like, from a quick search on google, that you have to include the
      full url when you try to do it this way. I've used the .href approach
      before and gotten away with not including the full url.




      Comment

      Working...