if (!isset($_SERVER['PHP_AUTH_USER'])) {
 header(‘WWW-Authenticate: Basic realm=”Panel Administracyjny”‘);
 header(‘HTTP/1.0 401 Unauthorized’);
 echo ‘Tekst, gdy użytkownik wciśnie przycisk Anuluj’;
 exit;
} else {
 echo „<p>User {$_SERVER['PHP_AUTH_USER']}.</p>”;
 echo „<p>Hasło {$_SERVER['PHP_AUTH_PW']}.</p>”;
}


if ( ! isset($_REQUEST['drukuj']) || $_REQUEST['drukuj']==” )
{
header(„Location: login.php”);
exit();
}
elseif (count( $druk) == 0)
{
header(„Location: login.php?err=Nie wskazano zadnych przedmiotow do druku”);
exit();
}


przez fsockopen: 

$header .= ‘GET … HTTP/1.0′.”\r\n”;
$header .= ‘Host: ‘.$domain.”\r\n”;
$header .= ‘Authorization: Basic ‘. base64_encode(‘login:haslo’).”\r\n”;
$header .= „\r\n”; 

$fp = @fsockopen ($host, 80, $errno, $errstr, 10);

if (!$fp) {
 $ret_value = „$errstr ($errno)”;
} else {
 …
}

 przez stream_context_create:

 $ctx = stream_context_create(
array(
‘http’ => array(
‘timeout’ => 12,
‘header’ => ‘Authorization: Basic ‘. base64_encode(‘login:haslo’)
)
)
);

$xml_data = file_get_contents($url, 0, $ctx);


header(„Cache-Control: no-cache, must-revalidate”); // HTTP/1.1
header(„Expires: Mon, 26 Jul 1997 05:00:00 GMT”);


if ($_SERVER[REQUEST_URI] == ‘/index.php’) {
header(‘Status: 301 Moved Permanently’);
header(‘Location: http://www.moa.waw.pl’);
exit;
}