You need to password protect content in PHP simply using .htaccess
You will require two files, the .htaccess and the .htpasswd files that needs to be in the location (directory) of the protected data.
In the .htaccess in side of the protected directory enter the following code
AuthName “restricted area”
If you are not sure what the full path is use the phpinfo() and locate the DOCUMENT_ROOT value
When done create the .htpasswd file with the user name and password MD5 hash for the accounts allowed to access the content
In the example above mike’s password is snowball and danny is flower. To generate this hash use one of the following links (all not tested):
- in section .htpasswd Username & Password Generator (https://davidwalsh.name/web-development-tools)