Can username:password be used in redirection

Discussion in 'PHP' started by mancade, Nov 21, 2007.

  1. #1
    Hi,

    I'm using the redirection syntax below, which results in the page being opened, but the username and password is requested in a dialogue box.

    header('Location: http://username:password@www.domain.com/');

    Can username:password syntax be used in this code line? And if so, why is the dialogue box still displayed? Is it because the username and password is requested by dialogue box, rather than as part of the page?

    Thanks in advance.

    Ade
     
    mancade, Nov 21, 2007 IP
  2. mancade

    mancade Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Please note that

    'Location: http://usernameassword@www.domain.com/'

    should actually read as

    'Location: http://username: password@www.domain.com/'

    without the space before the 'p' in password.
     
    mancade, Nov 21, 2007 IP
  3. bobb1589

    bobb1589 Peon

    Messages:
    289
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #3
    he knwos that but when he typed : p together it made that smiley...
     
    bobb1589, Nov 21, 2007 IP
  4. misja

    misja Active Member

    Messages:
    61
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    95
    #4
    No, it's not allowed to use username and password like this in the HTTP Location header.

    Try redirecting in the HTML code via META refresh or JavaScript ...
     
    misja, Nov 22, 2007 IP
  5. mancade

    mancade Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks misja
     
    mancade, Nov 22, 2007 IP