Announcement

Collapse
No announcement yet.

PHP_AUTH_USER question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PHP_AUTH_USER question

    Hi
    Here is my login code, could someone tell me what i put on account.php so the user is required to be logged in or account.php wont be accessable,

    [PHP<?php

    define('USER', 'user');
    define('PASSWORD', 'password');

    if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])) {
    header('WWW-Authenticate: Basic realm="My Realm"');
    header('HTTP/1.0 401 Unauthorized');
    echo 'Authorization Required.';

    } elseif (
    isset($_SERVER['PHP_AUTH_USER']) && $_SERVER['PHP_AUTH_USER'] == USER &&
    isset($_SERVER['PHP_AUTH_PW']) && $_SERVER['PHP_AUTH_PW'] == PASSWORD
    ) {
    header("Location: account.php");
    } else {
    header('WWW-Authenticate: Basic realm="My Realm"');
    header('HTTP/1.0 401 Unauthorized');
    echo "Authorization Required.";
    }
    ?> [/PHP]

  • #2
    Probably get more replies in the PHP question forum..
    MCSE, MVP, CCIE
    Microsoft Beta Team

    Comment

    widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
    Working...
    X