SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Hybrid View

  1. #1
    SitePoint Wizard
    Join Date
    May 2003
    Location
    Berlin, Germany
    Posts
    1,829
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $PHP_Auth_User and DB queries

    Hi,

    is there a possibility to check the input from the form of a password protected directory which would set $PHP_AUTH_USER ? Such as compare it to a database entry ?

    Thanks.

  2. #2
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DarkAngelBGE
    Hi,

    is there a possibility to check the input from the form of a password protected directory which would set $PHP_AUTH_USER ? Such as compare it to a database entry ?

    Thanks.
    Don't see why not -- after grabbing $PHP_AUTH_USER & $PHP_AUTH_PASS, just compare to the database.

    PHP Code:
    $user mysql_escape_string($PHP_AUTH_USER);
    $pass mysql_escape_string($PHP_AUTH_PASS);

    $result mysql_query("SELECT * FROM users WHERE user='$user' AND pass='$pass'");

    if (
    mysql_num_row($result) > 0) {
       
    //User logged in here
    } else {
       
    //Error message shown here

    My name is Steve, and I'm a super-villian.

  3. #3
    SitePoint Wizard
    Join Date
    May 2003
    Location
    Berlin, Germany
    Posts
    1,829
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Duh, I got it wrong then from the manual. I thought $PHP_AUTH_USER gets set only if the user is logged in. The source of comparison would be some entries in cpanel or so.

    Nevermind and thanks.

    /Edit: Setting up such a system works with using "Password Protected Directories" (via Cpanel or so) correct ?

  4. #4
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DarkAngelBGE
    Duh, I got it wrong then from the manual. I thought $PHP_AUTH_USER gets set only if the user is logged in. The source of comparison would be some entries in cpanel or so.

    Nevermind and thanks.

    /Edit: Setting up such a system works with using "Password Protected Directories" (via Cpanel or so) correct ?
    Never used CPanel myself, but if it operates on .htaccess & .htpasswd, then yes -- this will work the same way
    My name is Steve, and I'm a super-villian.

  5. #5
    SitePoint Evangelist N9ne's Avatar
    Join Date
    Aug 2002
    Location
    UK
    Posts
    596
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DarkAngelBGE
    Duh, I got it wrong then from the manual. I thought $PHP_AUTH_USER gets set only if the user is logged in. The source of comparison would be some entries in cpanel or so.

    Nevermind and thanks.

    /Edit: Setting up such a system works with using "Password Protected Directories" (via Cpanel or so) correct ?
    Yeah it will work with cPanel, cPanel creates .htaccess and .htpasswd files when you use that feature .

  6. #6
    SitePoint Wizard
    Join Date
    May 2003
    Location
    Berlin, Germany
    Posts
    1,829
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alright, thanks.

  7. #7
    SitePoint Wizard
    Join Date
    May 2003
    Location
    Berlin, Germany
    Posts
    1,829
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anybody know if it works with plesk panel as well ? I made a password protected directory there and also had to "make" a user for it. But once I access this protected dir via http I just get a forbidden 404 error instead of a login form. Any idea ?


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
  •