By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,719 Members | 1,439 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,719 IT Pros & Developers. It's quick & easy.

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

P: n/a
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.
Jul 17 '05 #1
Share this Question
Share on Google+
12 Replies


P: n/a
C-man wrote:
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.


if($access == 0) {
header("Location: admin.php");
}
else {
header("Location: 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
http://www.electrictoolbox.com/
Jul 17 '05 #2

P: n/a
Chris Hope wrote:
header("Location: user.php");


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

--
Jock
Jul 17 '05 #3

P: n/a
John Dunlop wrote:
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.


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
http://www.electrictoolbox.com/
Jul 17 '05 #4

P: n/a
Chris Hope wrote:
BTW a URI is the full path including the http:// and domain name etc


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
Jul 17 '05 #5

P: n/a
"John Dunlop" <us*********@john.dunlop.name> wrote in message
news:MP************************@News.Individual.NE T...
Chris Hope wrote:
header("Location: user.php");


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


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

http://www.microsoft.com/
Jul 17 '05 #6

P: n/a
Chung Leong wrote:
"John Dunlop" <us*********@john.dunlop.name> wrote in message
news:MP************************@News.Individual.NE T...
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.

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

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

The rule "absoluteURI", 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
IE has no problems with relative URLs in the location field.


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

--
Jock
Jul 17 '05 #7

P: n/a
"John Dunlop" <us*********@john.dunlop.name> wrote in message
news:MP************************@News.Individual.NE T...
The rule "absoluteURI", 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
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! :-)
Jul 17 '05 #8

P: n/a
On Thu, 08 Apr 2004 19:26:25 -0400, Chung Leong wrote:
> 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! :-)

ROFL!!

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

Regards,

Ian

--
Ian.H
digiServ Network
London, UK
http://digiserv.net/

Jul 17 '05 #9

P: n/a
On Fri, 09 Apr 2004 00:14:42 GMT, "Ian.H" <ia*@WINDOZEdigiserv.net> wrote:
On Thu, 08 Apr 2004 19:26:25 -0400, Chung Leong wrote:
> 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! :-)


ROFL!!

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


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 <an**@andyh.co.uk> / Space: disk usage analysis tool
http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
Jul 17 '05 #10

P: n/a
On Fri, 09 Apr 2004 01:26:35 +0100, Andy Hassall wrote:
On Fri, 09 Apr 2004 00:14:42 GMT, "Ian.H" <ia*@WINDOZEdigiserv.net> wrote:
On Thu, 08 Apr 2004 19:26:25 -0400, Chung Leong wrote:
> 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! :-)
ROFL!!

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


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

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 =)

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...

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
http://digiserv.net/

Jul 17 '05 #11

P: n/a
On Fri, 09 Apr 2004 00:42:50 GMT, "Ian.H" <ia*@WINDOZEdigiserv.net> wrote:
On Fri, 09 Apr 2004 01:26:35 +0100, Andy Hassall wrote:
On Fri, 09 Apr 2004 00:14:42 GMT, "Ian.H" <ia*@WINDOZEdigiserv.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 ;-)


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 =)


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...
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...


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.


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.
WinBSD anyone?


Eek.

--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
Jul 17 '05 #12

P: n/a
On Fri, 09 Apr 2004 02:09:29 +0100, Andy Hassall wrote:
On Fri, 09 Apr 2004 00:42:50 GMT, "Ian.H" <ia*@WINDOZEdigiserv.net>
wrote:
On Fri, 09 Apr 2004 01:26:35 +0100, Andy Hassall wrote:
On Fri, 09 Apr 2004 00:14:42 GMT, "Ian.H" <ia*@WINDOZEdigiserv.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 ;-)
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 =)


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.

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 =)

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...

lol.

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...


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.


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.

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.

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

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
http://digiserv.net/

Jul 17 '05 #13

This discussion thread is closed

Replies have been disabled for this discussion.