Read password from file

Hello.

I have a PHP3 script that ask the user to type in username and password by sending an 'HTTP/1.0 401 Unauthorized' heading.
This is then stored in the $PHP_AUTH_USER and $PHP_AUTH_PW variables.

How can I validate the passwords against a file on the server?

I use a free web host so I can't change anything on the server.

I found the script on http://hotwired.lycos.com/webmonkey/. There is an example on how to validate agains a text file, but it won't work, only the last password in the file works properly.

Thanks

Endre
esolemAsked:
Who is Participating?
 
gravityConnect With a Mentor Commented:
Where it uses
$line = explode("\r", $file_contents);

 have you tried using instead :

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

0
 
us111Commented:
if your file looks:
joe:e487edf
dav:gt878e5

you can try $line = explode(":", $file_contents);

0
 
mrvithanCommented:
I think it isn't a big deal how you can read... But it is how you can secure your file....

PS. ... i just know "\n" is a new line on WinNT and "\r" is a new line on Unix..., isn't it?
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
us111Commented:
\n for newline
\r for carriage
0
 
maxkirCommented:
Hello ? Did you get what you want ? It whould be nice if you give some points ;-)))
0
 
esolemAuthor Commented:
Hello all.

Thanks all. Rigth now I have put my project on ice and don't know when I can take it up again.

I give the points to gravity for beeing the first to answer, and I think that was my problem.

Endre
0
All Courses

From novice to tech pro — start learning today.