Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    May 2003
    Location
    Chicago, IL
    Posts
    131
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Redirect function not exicuting as expected

    I have a file management application whose login process is functioning differently across different browsers. In short, it works correctly in IE6, IE7, Chrome, and Opera 9. However, in FF and Safari it does not.

    I have 2 different types of users. "Clients" and "Administrators". In all browsers, after authenticating of the "client" UN' and PW', the user is redirected to the proper location. However, when an "administrator's" credentials are authenticated, that users is logged in but the location they are redirected to is not correct.
    PHP Code:
    function redirect_to_home()
    {
        
    //header('Location: client_upload.php');    
        
        
    if (isAdmin())
        {
            
    header('Location: UserAdmin.php');
        }
        else
        {
            
    header('Location: client_upload.php');            
        }

    When the user is an administrator, what occurs in both FF and Safari is that the URL to the location is not properly formed.

    When logging in the user is located at
    Code:
    http://www.site.com/fileTransfer/login.php/
    Once confirmed as an "administrator", in FF & Safari they are sent to
    Code:
    http://www.site.com/fileTransfer/login.php/UserAdmin.php
    rather than the correct location of
    Code:
    http://www.site.com/fileTransfer/UserAdmin.php
    (again: which does occur correctly in IE6, IE7, Chrome, and Opera 9)

    Odd to say the least...any clues?

    Thanks

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Absolute paths are not an option.
    According to RFC2616 http 1.1 specification, use of Location requires an absolute URI.
    So, change up you're info from UserAdmin.php to http://www.site.com/fileTransfer/UserAdmin.php.

    You can use PHP to detect and build these url's for you as well based on the current host. This is handy if you're using the same software on different hosts.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • Users who have thanked Fou-Lu for this post:

    hothousegraphix (12-19-2008)

  • #3
    Regular Coder lokeshshettyk's Avatar
    Join Date
    Aug 2008
    Location
    On the way to the moon!
    Posts
    157
    Thanks
    5
    Thanked 20 Times in 20 Posts
    Try specifying the absolute url in the header. It's recommended by PHP

  • Users who have thanked lokeshshettyk for this post:

    hothousegraphix (12-19-2008)

  • #4
    Regular Coder
    Join Date
    May 2003
    Location
    Chicago, IL
    Posts
    131
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thank you both for responding so quickly. I will make these changes and post back my results later.

    I appreciate the assistance.

    Thanks

  • #5
    Regular Coder
    Join Date
    May 2003
    Location
    Chicago, IL
    Posts
    131
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thank you both for the help, this was in fact my problem.

    Regards.


  •  

    Posting Permissions

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