i'm using http authentication for my php pages
(members area). Once you login correctly, than you can
access anypage as the authentication box doesn't
pop-up. 

Now i woul like to create a logout link after clicking
on which, whenever you click on a page using auth, the
auth box should pop-up again and you must feed in your
user/pass. What should this logout page contain? what
coding do i have to do?
>From what i understand, there is a $auth which is
"False" by default. When auth is succesfull, it
contains "True". And once it's true, the auth box
doesn't pop-up. I understand that probably clicking on
this "logout" link should again make $auth false. But
then $auth is on a lot of pages, how does this $auth
on logout.php3 make all the other $auth's false?

or is there some other way?

the code i'm using for auth is :

***
<?php 
$auth = false; // Assume user is not authenticated 
if (isset( $PHP_AUTH_USER ) && isset($PHP_AUTH_PW)) { 
    
        mysql_connect('localhost','root') or die (
'Unable to connect to server.' ); 
        mysql_select_db( 'skynet' ) or die ( 'Unable
to select database.' ); 

    // Formulate the query 

    $sql = "SELECT * FROM register WHERE 
            username = '$PHP_AUTH_USER' AND 
            password = '$PHP_AUTH_PW'"; 

    // Execute the query and put results in $result 

    $result = mysql_query( $sql ) or die ( 'Unable to
execute query.' ); 

    // Get number of rows in $result. 
    $num = mysql_numrows( $result ); 
    if ( $num != 0 ) { 

        // A matching row was found - the user is
authenticated. 

        $auth = true; 
    } 
} 

if ( ! $auth ) { 

    header( 'WWW-Authenticate: Basic realm="Private"'
); 
    header( 'HTTP/1.0 401 Unauthorized' ); 
    echo 'Authorization Required.'; 
    exit; 

} else { 

%%stuff 2 do%%

}
?>
***

Regards,
T. Edison jr.



=====
Rahul S. Johari (Director)
******************************************
Abraxas Technologies Inc.
Homepage : http://www.abraxastech.com
Email : [EMAIL PROTECTED]
Tel : 91-4546512/4522124
*******************************************

__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to