[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl-WebCGI] reading from a text file



At 15:56 +0100 8/17/99, James Fox wrote:
> I have created a script that adds usernames and passwords to a
> text file. the text file looks like this....

Is this a CGI script? (This is the web-cgi list but you don't specifiy...)

>
> james:fruit:james@djassociates.com:james:fox:0
> steve:pass:steve@you.com:Steve:someone:0
>
> Each user has their own line of text, with their username followed
> by a : then their password.

Lincoln Stein has written an "adduser" CGI script that specifically does
not use the Unix password file. Take a look at it for ideas...
http://stein.cshl.org/~lstein/user_manage/

>
> I want help in creating a login script whereby they login with their
> userID and password (which the script will check from this text file
> whether they are a valid username + pass) and then receive the
> rest of their details on their 'line' of text. (but no other line).
>
> If anyone can offer advice on how to go about doing this, or has a
> script similar that they could share with me, It would be
> appreciated.
> Thanks

Make _sure_ that there is exactly one entry for each given user ID (the
"unique key".

You could read the file into a hash each time you want to access it; for a
large file, consider using DBM.

Or consider storing the text in Boulder Data Interchange format
http://stein.cshl.org/software/boulder/

Once you have the data in a hash (indexed by username), you can ask "does
this username exist?"... "what is the password for that username? what is
the data for that username?

- Vicki
-- --
       |\      _,,,---,,_       Vicki Brown <vlb@cfcl.com>
 ZZZzz /,`.-'`'    -.  ;-;;,_   Journeyman Sourceror: Scripts & Philtres
      |,4-  ) )-,_. ,\ (  `'-'  P.O. Box 1269  San Bruno  CA  94066
     '---''(_/--'  `-'\_) http://www.cfcl.com/~vlb  http://www.macperl.com

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-webcgi-request@macperl.org