I am a beginner but I have some comments:

1. You should keep the passwords crypted on the file. It is simple to crypt
them

2. You can use "foreach(...) but if you will have a big file, it will eat
too much memory.
It would be even more simple to use "while(<FILE>)

3. Is the user allowed to  choose the username and password?
If yes, try to imagine what will happend, if the user will choose the
username user| and the password |pass|| or other combinations that  include
the |.
You use this character to separate the username and the password. You should
check first if they use this character.

Now, a simple solution would be something like:

my $FileWithPasswords = "/var/www/yourname/pass";

open (PASSFILE, $FileWithPasswords);

while (<PASSFILE>) {
chomp;
(my user, my pass) = split(/\|/, $_);
if ($user eq $username && $pass eq $password) {
#The username and password are OK. Do what you want here.
....
last;
}
#Don't put an "else" condition
#because the script will loop until it will find a good combination for
username/password.
#If there is no such combination, it will end the loop and then you can tell
that the username/password are wrong.

#end while
}
print "Bad username";
#Or do other things here

###

The $username and $password are the variables that you need to take from the
form.
You better encrypt the $password and also keep a crypted password in the
script file.

Teddy,
[EMAIL PROTECTED]

----- Original Message -----
From: "Ben Huyghebaert" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, June 12, 2002 3:51 PM
Subject: Having problems with login


>    I'm starting to make a perl/cgi/html based multi-player game called 3MF
(Massive Multiplayer Medieval Frolic).  So far I've made an account creation
screen that writes the data to two flat file db's one of them holds the
usernames & passwords, while the other holds all the user information.
>     Now I'm working on the login screen but I've run into some problems.
It only lets the last user account I create gain access.  For any others it
sends them to the invalid username and password screen I created.
>    Here is the code I'm using right now.  I open up the file with the
usernames and passwords and throw it all into @access and then do this
>
> foreach $i (@access) {
> chomp($i);
> ($un,$pw) =
> split(/\|/,$i);
> }
>
> $username = $FORM{'username'};
> $password = $FORM{'password'};
>
> if ($username ne "$un" or $password ne "$pw"){
> print <<NoPass; (block of html for invalid username/passwordscreen)
> NoPass
> }
> else {
> print <<YesPass; (block of html for Account manager screen)
> YesPass
> }
>
> So what do I need to fix to be able to match any username and password and
not just the last one created? and by the way all the data is being written
to the files and each entry is a new line.
> If anyone is interested in hearing more about my game concept and helping
out with any more problems I run into (there will be many) then let me know.
> Thanks
>
>
>
> -------------------------------------------------------------
> Sign up for ICQmail at http://www.icq.com/icqmail/signup.html
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to