First of all I would strongly recommend using DBI for this.  It will allow
you to use flat files now then upgrade to a database later with almost no
code changes.

That being said, there are a few ways you can do this, the simplest being
this:

# untested
my $valid_user = grep "$FORM{username}|$FORM{password}", @access;

....Or maybe this (a variation of yours):

my %users;
for ( @access ) {
  chomp;
  my ($u, $p) = split(/\|/, $_);
  $users{$u} = $p;
}

my $valid_user = ($users{$FORM{username}} eq $FORM{password}) ? 1 : 0;

Rob


-----Original Message-----
From: Ben Huyghebaert [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 12, 2002 8:51 AM
To: [EMAIL PROTECTED]
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