Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Read password from file

Posted on 2000-03-28
6
Medium Priority
?
211 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 300 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

926 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