View Single Post
Old 07-21-2005, 03:40 AM   #2 (permalink)
d*d
Addict
 
d*d's Avatar
 
I use php, it depends on the level of security your going after

you could try the following code, it's pretty standard. put it in a seperate file called authentication.php and put

include('../authentication.php');

at the top of all pages you want pasword protected.

put the following in php tags
// This page handles the authentication for the admin pages.

$authorized = FALSE; // Initialize a variable.

// Check for authentication submission.
if ( (isset($HTTP_SERVER_VARS['PHP_AUTH_USER']) AND isset($HTTP_SERVER_VARS['PHP_AUTH_PW'])) ) {

if ( ($HTTP_SERVER_VARS['PHP_AUTH_USER'] == 'name') AND ($HTTP_SERVER_VARS['PHP_AUTH_PW'] == 'password') ) { // If the correct values were entered...
$authorized = TRUE;
} else {
$authorized = FALSE;
}
} else {
$authorized = FALSE;
}

// If they haven't been authorized, create the pop-up window.
if ($authorized == FALSE) {
header('WWW-Authenticate: Basic realm="Administration"');
exit(); // For cancellations.
}
d*d is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62