Here is a short script that I wrote a while back. Just change the data accordingly. It reads from a flat text file that looks something like this:
user1,password1
user2,password2
user3,password3
Save it as data.txt. The txt file must also be comma delimited.
Here is the script. I think that it is pretty self explanatory.
[tt]
#!usr/bin/perl
# location of the txt file
$datadir = "e:\\nameofyourserver\\yoursite.com\\
# collect the data from the user using Post
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
if ($FORM{'action'} eq "checkpassword"

{ &checkpassword; }
else { &default; }
sub default {
print "Content-type: text/html\n\n";
print "<html>\n<head>\n<title>Enter your user name and Password</title>\n</head>\n";
print "<body>\n";
print "<form method=\"post\">\n";
print "<input type=\"hidden\" value=\"checkpassword\" name=\"action\">\n";
print "<font face=\"verdana\" size=\"-2\" color=\"black\"><b>username:</b></font>\n";
print "<br><input type=\"text\" name=\"user\" style=\"background:00648E; color:white; height:20; font-size:10px;\"><br>\n";
print "<font face=verdana size=-2 color=black><b>password:</b></font>\n";
print "<br><input type=\"password\" name=\"password\" style=\"background:00648E; color:white; height:20; font-size:10px;\"><br>\n";
print "<input type=\"submit\" value=\"Enter\" style=\"background:black; color:white; height:20; font-size:10px;\">\n";
print "<input type=\"Reset\" value=\"Clear\" style=\"background:black; color:white; height:20; font-size:10px;\">\n";
print "</form>\n";
print "</body>\n</html>\n";
}
sub checkpassword {
open(FILE, "$datadir/data.txt"

|| die("File does not reside on server: $!"

;
while (<FILE>) {
@data = split(/\n/);
foreach $entry (@data) {
($user, $password) = split(/,/, $entry);
if ($FORM{'user'} eq "$user"

{
$userverified = "1";
}
if ($FORM{'password'} eq "$password"

{
$passwordverified = "1";
}
}
}
close(FILE);
if ($userverified && $passwordverified) {
&accessgranted;
} elsif ($userverified) {
&badpassword;
} else {
&baduserpass;
}
}
sub accessgranted {
print "content-type: text/html\n\n";
print "<html><head><title>access granted</title></head>\n";
print "<body>\n";
print "<h1>access granted</h1>\n";
print "welcome to the
by me, vic cherubini.\n";
print "<br>select what you want to do.\n";
print "</body>\n";
print "</html>\n";
}
sub badpassword {
print "content-type: text/html\n\n";
print "<html><head><title>bad password</title></head>\n";
print "<body>\n";
print "<h1>bad password</h1>\n";
print "</body>\n";
print "</html>\n";
}
sub baduserpass {
print "content-type: text/html\n\n";
print "<html><head><title>bad username and password</title></head>\n";
print "<body>\n";
print "<h1>bad username and password</h1>\n";
print "</body>\n";
print "</html>\n";
}
[/tt]
If you need more help, don't hesitate to ask.
-Vic
vic cherubini
malice365@hotmail.com
====
Knows: Perl, HTML, JavScript, C/C++, PHP, Flash, Director
Wants to Know: Java, Cold Fusion, Tcl/TK
====