I have a series of usernames and passwords stored in a MySQL database. Is it possible to pull these out of the database and create a .htpasswd file dynamically (in other words, every time someone tries to log in)? I tried this:
<?
mysql_connect("localhost", "username", "password");
mysql_select_db("dbname");
$passwordsql = mysql_query("SELECT username, password FROM members");
while ($member = mysql_fetch_array($passwordsql)) {
echo $member['username'] . ":" . crypt($member['password']);
}
mysql_close();
?>
Didn't work though. Any other ideas?
<?
mysql_connect("localhost", "username", "password");
mysql_select_db("dbname");
$passwordsql = mysql_query("SELECT username, password FROM members");
while ($member = mysql_fetch_array($passwordsql)) {
echo $member['username'] . ":" . crypt($member['password']);
}
mysql_close();
?>
Didn't work though. Any other ideas?