Basic HTTP Authentication with PHP
HTTP authentication protection that can be used to restrict access to a page. This causes the browser to show a pop up message box to enter username and password. Below is a sample code for HTTP authentication: <?php if(!defined('PHP_AUTH_USER')){ define('PHP_AUTH_USER','root'); } if(!defined('')){ define('PHP_AUTH_PW','toor'); } if (!isset($_SERVER['PHP_AUTH_USER'])) { header('WWW-Authenticate: Basic realm="Restricted Area"'); header('HTTP/1.0 401 Unauthorized'); echo 'You are not authorized to access this page.'; exit; } else { if( $_SERVER['PHP_AUTH_USER']==PHP_AUTH_USER && $_SERVER['PHP_AUTH_PW']==PHP_AUTH_PW){ //do your operation here. }else{ header('WWW-Authenticate: Basic realm="Authori...