http://www.php.net/features.http-auth
FYI,
This is missing important information
.htaccess file should contain these two lines:
RewriteEngine on
RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization},last]
That tells the Apache Web server to pass the encrypted username and password to PHP in a variable namedHTTP_AUTHORIZATION.
http://support.tigertech.net/php-http-auth