using Flat File

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Guys,

i wondered if there any assistance you could do for me on this code.

I have called on God many times to assist me but He did not respond.

I hope you would.

What I am trying to do is to allow certain users to view a certain page . I stored their names and passwords in a file.txt

But the is not working is there any help??

<?php  

$auth = false;  
if (isset( $PHP_AUTH_USER ) &amp;&amp; isset($PHP_AUTH_PW)) {  

    
    $filename = 'c:\\php_data\\file.txt'; 
    $f = @fopen($filename, "r");          
     if ($f != FALSE)  
     {    $a = @fread($f, filesize($filename)); 
            fclose($f);  
     }  
     else  
     {  
          echo "Could not open file";  
     }  



    $lines = explode ( "\n", $file_contents );  

    

    foreach ( $lines as $line ) {  

        list( $username, $password ) = explode( ':', $line );  

        if ( ( $username == "$PHP_AUTH_USER" ) &amp;&amp;  
             ( $password == "$PHP_AUTH_PW" ) ) {  

         
   

            $auth = true;  
            break;  

        }  
    }  

}  

if ( ! $auth ) {  

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

} else {  

    echo '<P>You are authorized!</P>';  
}  

?>  





---------------------------------
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux