This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For http basic authentication in php | |
//Just add this code on top before any echo or print in common file | |
$user = 'user'; | |
$password = 'pass'; | |
if (!($_SERVER['PHP_AUTH_USER'] == $user && $_SERVER['PHP_AUTH_PW'] == $password)) { | |
header('WWW-Authenticate: Basic realm="Please enter username and password to access tgis website"'); | |
header('HTTP/1.0 401 Unauthorized'); | |
echo '<h1>Unauthorized Access</h1>'; | |
exit; | |
} |