Solved

Read password from file

Posted on 2000-03-28
6
178 Views
Last Modified: 2008-02-01
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
0
Comment
Question by:esolem
6 Comments
 
LVL 2

Accepted Solution

by:
gravity earned 100 total points
ID: 2664609
Where it uses
$line = explode("\r", $file_contents);

 have you tried using instead :

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

0
 
LVL 8

Expert Comment

by:us111
ID: 2668131
if your file looks:
joe:e487edf
dav:gt878e5

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

0
 

Expert Comment

by:mrvithan
ID: 2668715
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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 8

Expert Comment

by:us111
ID: 2668907
\n for newline
\r for carriage
0
 
LVL 2

Expert Comment

by:maxkir
ID: 2693330
Hello ? Did you get what you want ? It whould be nice if you give some points ;-)))
0
 

Author Comment

by:esolem
ID: 2808926
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

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now