JDM71488
08-31-2003, 08:38 PM
Hello, I need some help with my script... I am using the PHP_AUTH_USER & PHP_AUTH_PW pop up login box...
Well, I need a way to make it where the is a way to end the session, or logout. I know I can close the browser window, but this makes it very inconvieniant (spelling???).
Also, if there would be a way to throw in a blocker for all protected pages, that would be great...
Any help is appreciated!!!!
<?php
$auth = false; // Assume user is not authenticated
if (isset( $PHP_AUTH_USER ) && isset($PHP_AUTH_PW)) {
mysql_connect( 'localhost', 'username', 'password' )
or die ( 'Unable to connect to server.' );
mysql_select_db( 'jdm71488_test' )
or die ( 'Unable to select database.' );
$sql = "SELECT * FROM users WHERE
user = '$PHP_AUTH_USER' AND
pass = '$PHP_AUTH_PW'";
$result = mysql_query( $sql )
or die ( 'Unable to execute query.' );
$num = mysql_numrows( $result );
if ( $num != 0 ) {
$auth = true;
}
}
if ( ! $auth ) {
header( 'WWW-Authenticate: Basic realm="JDM Enterprises"' );
header( 'HTTP/1.0 401 Unauthorized' );
echo 'Authorization Required.';
exit;
} else {
setcookie ("verified", "true");
header("Location:http://www.jdm71488.com/members/secure.php");
}
?>
Well, I need a way to make it where the is a way to end the session, or logout. I know I can close the browser window, but this makes it very inconvieniant (spelling???).
Also, if there would be a way to throw in a blocker for all protected pages, that would be great...
Any help is appreciated!!!!
<?php
$auth = false; // Assume user is not authenticated
if (isset( $PHP_AUTH_USER ) && isset($PHP_AUTH_PW)) {
mysql_connect( 'localhost', 'username', 'password' )
or die ( 'Unable to connect to server.' );
mysql_select_db( 'jdm71488_test' )
or die ( 'Unable to select database.' );
$sql = "SELECT * FROM users WHERE
user = '$PHP_AUTH_USER' AND
pass = '$PHP_AUTH_PW'";
$result = mysql_query( $sql )
or die ( 'Unable to execute query.' );
$num = mysql_numrows( $result );
if ( $num != 0 ) {
$auth = true;
}
}
if ( ! $auth ) {
header( 'WWW-Authenticate: Basic realm="JDM Enterprises"' );
header( 'HTTP/1.0 401 Unauthorized' );
echo 'Authorization Required.';
exit;
} else {
setcookie ("verified", "true");
header("Location:http://www.jdm71488.com/members/secure.php");
}
?>