I wrote this code to create an authentication script that will only work with one user but allow the credientals to be passed from one page to another. So here's the code
CODE
<?PHP
$aut = FALSE;
//Check for user variables
if ( (isset($_server['PHP_AUTH_USER']) AND isset($_server['PHP_AUTH_PW'])) ) {
//Check for correct user and password
$user = $_server['PHP_AUTH_USER'];
$pw = $_server['PHP_AUTH_PW'];
if ($user == "user" AND $pw == "password"){
$aut = TRUE;
}
}
//IF not authorized ask for authentication
if ($aut == FALSE){
header('WWW-Authenticate: Basic realm="d-gression HTML editor"');
header('HTTP/1.0 401 Unauthorized'); //If cancel is pressed
}
?>
and the actual page the require points to the above code
CODE
<?PHP
require('./auth.inc');
if ($aut == FALSE){
echo "please <a href=\"index.php\">try again.</a>";
} else {
echo "you're in!!!";
}
?>
require('./auth.inc');
if ($aut == FALSE){
echo "please <a href=\"index.php\">try again.</a>";
} else {
echo "you're in!!!";
}
?>

