Solved

Read password from file

Posted on 2000-03-28
6
170 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
Comment Utility
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
Comment Utility
if your file looks:
joe:e487edf
dav:gt878e5

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

0
 

Expert Comment

by:mrvithan
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 8

Expert Comment

by:us111
Comment Utility
\n for newline
\r for carriage
0
 
LVL 2

Expert Comment

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

Author Comment

by:esolem
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
spacing 5 24
Get Javascript URL parameters 7 27
How do I edit this Drupal page? 9 26
Help cleaning out CSS 2 21
Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

763 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

10 Experts available now in Live!

Get 1:1 Help Now