The fastest and easiest way to do basic authentication on the web is with .htaccess/.htpasswd. Let me remind you how to do this:
1. Create a file on the server:
.htaccess
within it:
AuthType Basic
AuthName "Your authorization required message."
AuthUserFile /home/user/vasya/public_html/.htpasswd
require valid-user
php_value display_errors 1
In AuthUserFile, you need to set the absolute path to the login-password file. To find out the path, we put the script in the folder:
path.php
inside:
<?php
echo dirname(__FILE__) . '/.htpasswd';
?>
Open it and find out the way.
2. Create file
.htpasswd
inside:
vasya:<password in MD5>
Note that a normal MD5 generator will not work, apache has its own MD5 hash structure. Google “md5 .htaccess” giner
3. Make a link for auto-entry
http://username:password@www.vasya.com/folder