Authentication: htaccess and htpasswd

Discussion in 'PHP' started by blackburn2413, Sep 1, 2010.

  1. #1
    Hello everyone, I need some basic authentication and this is the type of security that I have decided to go with. I have set it up and am able to use it just fine with everything working.

    My question is, is there a way to add something to my "Admin" page so that the admin can edit the .htpasswd file right from a web page and add another user \ change password?

    If anyone has an example of this I would be greatly appreciative. Also any ideas to point me in the right direction would be greatly appreciated too.

    Thanks!
     
    blackburn2413, Sep 1, 2010 IP
  2. ndevendra

    ndevendra Member

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #2
    1. chmod 0777 to the file .htpasswd for writing
    2. .htpasswd file stores username and password in the form username:crypt(password). So, prepare the php code so as to write the lines in the same format.
    3. You can add users in the next line if you want multi users to access the same foler. Or just edit the same line in the format username:crypt(password)
    4. U may find reference to php crypt command anywhere.
    5. chmod .htpasswd back to 0644.
     
    ndevendra, Sep 2, 2010 IP
  3. TheDataPlanet.com

    TheDataPlanet.com Well-Known Member

    Messages:
    503
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    108
    #3
    Try this PHP class to generate and edit .htpasswd files. Just use the addUser() method to add a user and deleteUser() to delete a user from a certain .htpasswd file.
     
    TheDataPlanet.com, Oct 3, 2010 IP