Pasword protected folder username

Discussion in 'PHP' started by hasbehas, Jul 20, 2010.

  1. #1
    Just wondering..

    Cpanel has Password protect directories. I assigned a username and a password to protect a file.

    Is it possible to get the username and print on the protected page ?

    Like "Hello Hasbehas.." . Presuming username is "hasbehas"

    Is it possible to get this data, or Would I need a new script to do this ?
     
    hasbehas, Jul 20, 2010 IP
  2. Deacalion

    Deacalion Peon

    Messages:
    438
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Take a look at $_SERVER["REMOTE_USER"]
     
    Deacalion, Jul 20, 2010 IP
  3. bencummins

    bencummins Peon

    Messages:
    55
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I'm not sure how cpanel implement their logins, but if you were to create a php page, behind the secure login, with something like

    <pre><? print_r($_SERVER); ?></pre>
    
    PHP:
    You will be able to find out the variables the server has stored..

    You might need $_SERVER["PHP_AUTH_USER"], and can show it on a page using
    <?=$_SERVER["PHP_AUTH_USER"];?>
    
    PHP:
     
    bencummins, Jul 20, 2010 IP
  4. ashishhbti

    ashishhbti Peon

    Messages:
    67
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Yes you can use $_SERVER["PHP_AUTH_USER"] to display username...


    Thanks
     
    ashishhbti, Jul 21, 2010 IP
  5. dacash

    dacash Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    print_r($_SERVER); // is your best friend for this :) you can see all the data the server has on the current HTTP request.
     
    dacash, Jul 21, 2010 IP