How do I redirect to a new php file from the one I am in?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • C-man

    How do I redirect to a new php file from the one I am in?

    Basically I have a login.php script that takes the users login and password,
    I then search in the database for the entry and discover if they have access
    0 which is admin or access 1 which is normal user. Based on this I want to
    redirect the user to a new php file. Either admin.php or user.php depending
    on the access level.=l. Simple solution I am sure.

    Thanks for the help.


  • Chris Hope

    #2
    Re: How do I redirect to a new php file from the one I am in?

    C-man wrote:
    [color=blue]
    > Basically I have a login.php script that takes the users login and
    > password, I then search in the database for the entry and discover if they
    > have access 0 which is admin or access 1 which is normal user. Based on
    > this I want to redirect the user to a new php file. Either admin.php or
    > user.php depending on the access level.=l. Simple solution I am sure.[/color]

    if($access == 0) {
    header("Locatio n: admin.php");
    }
    else {
    header("Locatio n: user.php");
    }

    I'm pretty sure I once read somewhere that the filename specified is
    supposed to be a full url containing the domain name etc as well but it's
    always worked for me just specifying the filename.

    Chris

    --
    Chris Hope
    The Electric Toolbox Ltd

    Comment

    • John Dunlop

      #3
      Re: How do I redirect to a new php file from the one I am in?

      Chris Hope wrote:
      [color=blue]
      > header("Locatio n: user.php");[/color]

      That's a relative URL. The authoritative source, RFC2616, says the
      Location header "field value consists of a single absolute URI". For
      practical purposes, in my opinion, we can take "URI" here to mean
      "URI reference", i.e., the absolute URI could be accompanied by a
      fragment identifier.



      --
      Jock

      Comment

      • Chris Hope

        #4
        Re: How do I redirect to a new php file from the one I am in?

        John Dunlop wrote:
        [color=blue]
        > That's a relative URL. The authoritative source, RFC2616, says the
        > Location header "field value consists of a single absolute URI". For
        > practical purposes, in my opinion, we can take "URI" here to mean
        > "URI reference", i.e., the absolute URI could be accompanied by a
        > fragment identifier.[/color]

        Thanks for that. As you will of course noted I did say that I thought this
        was the case in my posting, but that a relative url has always worked for
        me in the past (with a variety of browsers I might add).

        BTW a URI is the full path including the http:// and domain name etc

        Chris

        --
        Chris Hope
        The Electric Toolbox Ltd

        Comment

        • John Dunlop

          #5
          Re: How do I redirect to a new php file from the one I am in?

          Chris Hope wrote:
          [color=blue]
          > BTW a URI is the full path including the http:// and domain name etc[/color]

          If you mean "an absolute HTTP URI", I largely agree -- the "full
          path" is optional. The only mandatory components of an absolute HTTP
          URL are the case-sensitive scheme name ("http"), the separating
          colon, the two solidi ("//") and the host name. See RFC2616, sec.
          3.2.2.

          The value of the HTTP Location header field isn't restricted to an
          absolute *HTTP* URL though. The only requirement is that it must
          consist of an absolute URI (read "URI reference"), as defined in
          RFC2396, sec. 3. Other URI schemes are implicitly allowed.

          --
          Jock

          Comment

          • Chung Leong

            #6
            Re: How do I redirect to a new php file from the one I am in?

            "John Dunlop" <usenet+2004@jo hn.dunlop.name> wrote in message
            news:MPG.1addcd 4619c763989896e 2@News.Individu al.NET...[color=blue]
            > Chris Hope wrote:
            >[color=green]
            > > header("Locatio n: user.php");[/color]
            >
            > That's a relative URL. The authoritative source, RFC2616, says the
            > Location header "field value consists of a single absolute URI". For
            > practical purposes, in my opinion, we can take "URI" here to mean
            > "URI reference", i.e., the absolute URI could be accompanied by a
            > fragment identifier.
            >
            > http://www.ietf.org/rfc/rfc2616.txt[/color]

            IE has no problems with relative URLs in the location field.




            Comment

            • John Dunlop

              #7
              Re: How do I redirect to a new php file from the one I am in?

              Chung Leong wrote:
              [color=blue]
              > "John Dunlop" <usenet+2004@jo hn.dunlop.name> wrote in message
              > news:MPG.1addcd 4619c763989896e 2@News.Individu al.NET...
              >[color=green]
              > > The authoritative source, RFC2616, says the Location header "field
              > > value consists of a single absolute URI". For practical purposes,
              > > in my opinion, we can take "URI" here to mean "URI reference", i.e.,
              > > the absolute URI could be accompanied by a fragment identifier.[/color][/color]

              It's not just my opinion. The errata discusses this. The correct
              ABNF for the Location header is:

              Location = "Location" ":" absoluteURI [ "#" fragment ]

              The rule "absoluteUR I", I presume, is defined in RFC2396, sec. 3, as
              it was in RFC2616, sec. 14.30; I *guess* "fragment" is defined in
              RFC2396, sec. 4.1, although the only mention in RFC2616 of fragment
              identifiers has nothing to do with Location headers, and the errata
              doesn't explicitly delegate "fragment"' s definition to anywhere.

              Find official errata and updates for HTTP standards from the Internet Engineering Task Force (IETF). Stay informed with accurate information.

              [color=blue]
              > IE has no problems with relative URLs in the location field.[/color]

              I would've accompanied that type of humour with a smiley.

              --
              Jock

              Comment

              • Chung Leong

                #8
                Re: How do I redirect to a new php file from the one I am in?

                "John Dunlop" <usenet+2004@jo hn.dunlop.name> wrote in message
                news:MPG.1adf37 917820c57e9896e 4@News.Individu al.NET...[color=blue]
                > The rule "absoluteUR I", I presume, is defined in RFC2396, sec. 3, as
                > it was in RFC2616, sec. 14.30; I *guess* "fragment" is defined in
                > RFC2396, sec. 4.1, although the only mention in RFC2616 of fragment
                > identifiers has nothing to do with Location headers, and the errata
                > doesn't explicitly delegate "fragment"' s definition to anywhere.
                >
                > http://skrb.org/ietf/http_errata.htm...tion-fragments
                >[color=green]
                > > IE has no problems with relative URLs in the location field.[/color]
                >
                > I would've accompanied that type of humour with a smiley.[/color]

                As far as I'm concerned the behavior of the de facto standard browser is the
                standard. Long live Redmond unilateralism! :-)


                Comment

                • Ian.H

                  #9
                  Re: How do I redirect to a new php file from the one I am in?

                  On Thu, 08 Apr 2004 19:26:25 -0400, Chung Leong wrote:
                  [color=blue][color=green][color=darkred]
                  >> > IE has no problems with relative URLs in the location field.[/color]
                  >>
                  >> I would've accompanied that type of humour with a smiley.[/color]
                  >
                  > As far as I'm concerned the behavior of the de facto standard browser is the
                  > standard. Long live Redmond unilateralism! :-)[/color]


                  ROFL!!

                  You owe me a new keyboard! lol this one's now covered in coffee =)



                  Regards,

                  Ian

                  --
                  Ian.H
                  digiServ Network
                  London, UK


                  Comment

                  • Andy Hassall

                    #10
                    Re: How do I redirect to a new php file from the one I am in?

                    On Fri, 09 Apr 2004 00:14:42 GMT, "Ian.H" <ian@WINDOZEdig iserv.net> wrote:
                    [color=blue]
                    >On Thu, 08 Apr 2004 19:26:25 -0400, Chung Leong wrote:
                    >[color=green][color=darkred]
                    >>> > IE has no problems with relative URLs in the location field.
                    >>>
                    >>> I would've accompanied that type of humour with a smiley.[/color]
                    >>
                    >> As far as I'm concerned the behavior of the de facto standard browser is the
                    >> standard. Long live Redmond unilateralism! :-)[/color]
                    >
                    >ROFL!!
                    >
                    >You owe me a new keyboard! lol this one's now covered in coffee =)[/color]

                    The Redmond mob do a nice line in keyboards ;-)

                    Actually if Microsoft software was up to the standard of their mice and
                    keyboards I'd have much less to complain about! But back to the real world...

                    --
                    Andy Hassall <andy@andyh.co. uk> / Space: disk usage analysis tool
                    http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space

                    Comment

                    • Ian.H

                      #11
                      Re: How do I redirect to a new php file from the one I am in?

                      On Fri, 09 Apr 2004 01:26:35 +0100, Andy Hassall wrote:
                      [color=blue]
                      > On Fri, 09 Apr 2004 00:14:42 GMT, "Ian.H" <ian@WINDOZEdig iserv.net> wrote:
                      >[color=green]
                      >>On Thu, 08 Apr 2004 19:26:25 -0400, Chung Leong wrote:
                      >>[color=darkred]
                      >>>> > IE has no problems with relative URLs in the location field.
                      >>>>
                      >>>> I would've accompanied that type of humour with a smiley.
                      >>>
                      >>> As far as I'm concerned the behavior of the de facto standard browser is the
                      >>> standard. Long live Redmond unilateralism! :-)[/color]
                      >>
                      >>ROFL!!
                      >>
                      >>You owe me a new keyboard! lol this one's now covered in coffee =)[/color]
                      >
                      > The Redmond mob do a nice line in keyboards ;-)[/color]


                      LOL! Can't say I've actually tried any.. just bought this one.. was a
                      whole 12 quid (PCLine).. but I go through keyboards like I do coffee =)

                      [color=blue]
                      > Actually if Microsoft software was up to the standard of their mice and
                      > keyboards I'd have much less to complain about! But back to the real world...[/color]


                      I've used a couple of their mice and they seemed "robust".. and as you
                      say, if they could get that sort of technology into their software, the
                      world would be a better place.

                      WinBSD anyone?



                      Regards,

                      Ian

                      --
                      Ian.H
                      digiServ Network
                      London, UK


                      Comment

                      • Andy Hassall

                        #12
                        Re: How do I redirect to a new php file from the one I am in?

                        On Fri, 09 Apr 2004 00:42:50 GMT, "Ian.H" <ian@WINDOZEdig iserv.net> wrote:
                        [color=blue]
                        >On Fri, 09 Apr 2004 01:26:35 +0100, Andy Hassall wrote:[color=green]
                        >> On Fri, 09 Apr 2004 00:14:42 GMT, "Ian.H" <ian@WINDOZEdig iserv.net> wrote:[color=darkred]
                        >>>
                        >>>ROFL!!
                        >>>
                        >>>You owe me a new keyboard! lol this one's now covered in coffee =)[/color]
                        >>
                        >> The Redmond mob do a nice line in keyboards ;-)[/color]
                        >
                        >LOL! Can't say I've actually tried any.. just bought this one.. was a
                        >whole 12 quid (PCLine).. but I go through keyboards like I do coffee =)[/color]

                        I've had this Microsoft 'Natural Keyboard' for years, the sort that's split
                        down the middle, and there is no way I'd give it up - it's basically a perfect
                        keyboard IMHO. Noticably easier to type on than the plain keyboard at the
                        office.

                        And it's relatively easy to clean drinks out of it after the odd couple of
                        accidents ;-) Haven't tried spilling coffee into it yet though...
                        [color=blue][color=green]
                        >> Actually if Microsoft software was up to the standard of their mice and
                        >> keyboards I'd have much less to complain about! But back to the real world...[/color]
                        >
                        >I've used a couple of their mice and they seemed "robust".. and as you
                        >say, if they could get that sort of technology into their software, the
                        >world would be a better place.[/color]

                        As per the usual Microsoft practice, they changed the design of the 'Natural'
                        range of keyboards in annoying ways, e.g. the ins/home/pgup group of keys are
                        2x3 instead of the proper 3x2 layout, and the cursor keys are diamond instead
                        of an inverted T. And half-height Function keys. Bleh. So basically the new
                        ones are rubbish, last time I looked anyway.

                        Their new mouse looks nice - with a 2D wheel (left+right as well as up+down
                        and middle-button click). A bit pricy though.
                        [color=blue]
                        >WinBSD anyone?[/color]

                        Eek.

                        --
                        Andy Hassall <andy@andyh.co. uk> / Space: disk usage analysis tool
                        http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space

                        Comment

                        • Ian.H

                          #13
                          [OT] Re: How do I redirect to a new php file from the one I am in?

                          On Fri, 09 Apr 2004 02:09:29 +0100, Andy Hassall wrote:
                          [color=blue]
                          > On Fri, 09 Apr 2004 00:42:50 GMT, "Ian.H" <ian@WINDOZEdig iserv.net>
                          > wrote:
                          >[color=green]
                          >>On Fri, 09 Apr 2004 01:26:35 +0100, Andy Hassall wrote:[color=darkred]
                          >>> On Fri, 09 Apr 2004 00:14:42 GMT, "Ian.H" <ian@WINDOZEdig iserv.net>
                          >>> wrote:
                          >>>>
                          >>>>ROFL!!
                          >>>>
                          >>>>You owe me a new keyboard! lol this one's now covered in coffee =)
                          >>>
                          >>> The Redmond mob do a nice line in keyboards ;-)[/color]
                          >>
                          >>LOL! Can't say I've actually tried any.. just bought this one.. was a
                          >>whole 12 quid (PCLine).. but I go through keyboards like I do coffee =)[/color]
                          >
                          > I've had this Microsoft 'Natural Keyboard' for years, the sort that's
                          > split
                          > down the middle, and there is no way I'd give it up - it's basically a
                          > perfect keyboard IMHO. Noticably easier to type on than the plain
                          > keyboard at the office.[/color]


                          I've never tried one of these "natural keyboards".. I've always though
                          they looked awkward to type on. I use most fingers to type with.. but not
                          in the style a secretary would (I have no "home keys" as such). I might
                          have to try one just for the sakes of comparison.. never know, I might
                          like it too =)

                          [color=blue]
                          > And it's relatively easy to clean drinks out of it after the odd couple
                          > of
                          > accidents ;-) Haven't tried spilling coffee into it yet though...[/color]


                          lol.

                          [color=blue][color=green][color=darkred]
                          >>> Actually if Microsoft software was up to the standard of their mice
                          >>> and
                          >>> keyboards I'd have much less to complain about! But back to the real
                          >>> world...[/color]
                          >>
                          >>I've used a couple of their mice and they seemed "robust".. and as you
                          >>say, if they could get that sort of technology into their software, the
                          >>world would be a better place.[/color]
                          >
                          > As per the usual Microsoft practice, they changed the design of the
                          > 'Natural'
                          > range of keyboards in annoying ways, e.g. the ins/home/pgup group of
                          > keys are 2x3 instead of the proper 3x2 layout, and the cursor keys are
                          > diamond instead of an inverted T. And half-height Function keys. Bleh.
                          > So basically the new ones are rubbish, last time I looked anyway.[/color]


                          I hate pretty much all "new keyboards".. this one I'm typing on now
                          included. The keyboard I've just ditched in replacement from this was from
                          my old 486 AST box.. none of these extra keys.. not even any "windoze
                          keys" 8)

                          This one has those stupid sleep, standby, blah blah buttons where print
                          screen, scroll lock etc used to be. Print screen etc have now been moved
                          down along with the 3x2 Insert, Home etc block. This becomes realy
                          annoying as I tend to hit scroll lock instad / aswell as Home etc. Some
                          are also coming with single-row height Return keys too and.......... argh!

                          I can handle the half-height F-keys as I don't use these _that_ often..
                          although I have some custom macros defined in UEdit / Anjuta that I use
                          them for.

                          [color=blue]
                          > Their new mouse looks nice - with a 2D wheel (left+right as well as
                          > up+down
                          > and middle-button click). A bit pricy though.[/color]


                          I saw this advertised somewhere the other day and was thinking the same...
                          would be great for coding to save you have to keep finding the scrollbar
                          on the odd occassion my lines are longer than the width of my editor.
                          Can't remember how much it was advertised for though.. might look into it
                          when I need my next mouse.



                          Regards,

                          Ian

                          --
                          Ian.H
                          digiServ Network
                          London, UK


                          Comment

                          Working...