Using .htaccess 












Using .htaccess/.htpasswd Password Protection 





Coding Tips 








Uploads and Downloads 



Mail 
see it on this page





Working with Images 


Frequently Requested Website Functionality 
see it on this page
see it on this page
see it on this page
see it on this page











Using PHP 




Website Managment 








Other Tips 









Auto generate .htpasswd file
This php script reads a MySQL database, encrypts the passwords and writes an htpasswd file. Using this script you can maintain a database of users and generate an .htpasswd file from the database.
<?php
$filename = "your htpasswd file path goes here"; // your htpasswd file name - complete unix path - or relative to this script
$host="host"; // database host address
$dbuser="user"; // database user name
$dbpswd="password"; // database password
$mysqldb="db_name"; // name of database
$table="passwd_table"; // name of table
// modify the above lines for your environment
mysql_connect("$host", "$dbuser", "$dbpswd");
mysql_select_db ("$mysqldb");
$query = mysql_query("SELECT * FROM $table");
while ($row = mysql_fetch_array($query)) {
$user = $row['user'];
$pass = $row['password'];
$encrypted = crypt($pass);
$record .= "$user:$encrypted\r\n";
}
file_put_contents($filename,$record);
?>
