What do you mean the code doesn't work? How is the code behaving? What kinds
of errors are being returned by the interpreter? Is your register_globals
set to ON or OFF? Are you certain you have access to the directory in which
the file you wish to open is located?

> -----Original Message-----
> From: web man [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 22, 2003 2:02 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] using Flat File
> 
> 
> 
> Hi,
> 
> I have posted my question to this list before but I did not 
> get a help that I was expected.
> 
> All I wanted to do is to give access for the users to view a 
> page in which the below code is embedded. The user will enter 
> his/her username and password.
> 
> But the code is not working.
> 
> I don't know what to think. 
> 
> I need your help guys. Don't let me die on this code 
> 
> <?php
> >
> > $auth = false;
> > if (isset( $PHP_AUTH_USER )  && 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
> 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to