You can do like this
<?php
if ( ( !isset( $PHP_AUTH_USER )) || (!isset($PHP_AUTH_PW))
|| ( $PHP_AUTH_USER != 'username' ) || ( $PHP_AUTH_PW != 'password' ) ) {
header( 'WWW-Authenticate: Basic realm="Private"' );
header( 'HTTP/1.0 401 Unauthorized' );
echo 'Authorization Required.';
exit;
} else {
echo 'You entered in a secure page. Put you code here';
?>
For more information search on www.zend.com,
there I found a lot of exemples. Sory but I lost the URL so you have to search for it.
Regards,
iugin