Et login-script
<php// File name: admin_menu.php
// Check to see if $PHP_AUTH_USER already contains info
if (!isset($PHP_AUTH_USER)) {
// if empty, send header causing dialog box to appear
header('WWW-Authenticate: Basic realm="XYZ Company Admin Area"');
header('HTTP/1.0 401 Unathorized');
echo 'Authorization Required :(';
exit;
}else if (isset($PHP_AUTH_USER)) {
if (($PHP_AUTH_USER != "admin") || ($PHP_AUTH_PW != "abc")) {
header('WWW-Authenticate: Basic realm="XYZ Company Admin Area"');
header('HTTP/1.0 401 Unauthorized');
echo 'Authorization Required.';
exit;
}else{
echo"
<html><body>
Hejsa
</body></html>
";
}
}
?>
Den skulle jo spørge om kode hvis man ikke er logget ind. Den går bare direkte til html-koden.
