SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot
    Join Date
    May 2007
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    question on location header

    Is it Ok(valid) to use a query string in a location header e.g
    header('location:login.php?id=$theid').
    A novice question,eh?

  2. #2
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    453
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes
    Computers and Fire ...
    In the hands of the inexperienced or uneducated,
    the results can be disastrous.
    While the professional can tame, master even conquer.

  3. #3
    Worship the Krome kromey's Avatar
    Join Date
    Sep 2006
    Location
    Fairbanks, AK
    Posts
    1,621
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    FYI, you should be using FQDNs in you location header:
    PHP Code:
    header("Location: http://mysite.com/login.php?id=$theid"); 
    Relative URLs will work, but are technically invalid.
    PHP questions? RTFM
    MySQL questions? RTFM

  4. #4
    SitePoint Addict
    Join Date
    Mar 2005
    Posts
    276
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kromey View Post
    FYI, you should be using FQDNs in you location header:
    PHP Code:
    header("Location: http://mysite.com/login.php?id=$theid"); 
    Relative URLs will work, but are technically invalid.
    in which way, will they break at some point or is it just bad practice?

    Thanks
    Chris

  5. #5
    Worship the Krome kromey's Avatar
    Join Date
    Sep 2006
    Location
    Fairbanks, AK
    Posts
    1,621
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If a UA (i.e. a browser) comes along that strictly follows standards then yes, it will break. However, as every browser currently out there makes allowances for violations like this, in actuality it is merely bad practice.

    Personally, I prefer to take the extra 2 seconds to make my location headers absolute URLs just in case a standards-strict browser does ever come along.
    PHP questions? RTFM
    MySQL questions? RTFM

  6. #6
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think they may be some issues with ssl-encrypted pages, if you don't follow the standard. I'm not sure, I just think I remember having a problem in that direction once.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •