Verifying a username and a password.
Type in your username and password below.
#!perl
use CGI qw(:standard);
$testUsername = param( "USERNAME" );
$testPassword = param( "PASSWORD" );
open ( FILE, "password.txt" ) || die "The database could not be opened";
while ( $line = )
{
chomp $line;
( $username, $password ) = split( ",", $line );
if ( $testUsername eq $username )
{
$userVerified = 1;
if ( $testPassword eq $password )
{
$passwordVerified = 1;
last;
}
}
}
close( FILE );
print header;
if ( $userVerified && $passwordVerified )
{
accessGranted();
}
elsif ( $userVerified && !$passwordVerified )
{
wrongPassword();
}
else
{
accessDenied();
}
sub accessGranted
{
print "Thank You";
print "Permission has been granted, $username.";
print "
Enjoy the site.";
}
sub wrongPassword
{
print "Access Denied";
print "You entered an invalid password.
";
print "Access has been denied.";
}
sub accessDenied
{
print "Access Denied";
print "You were denied access to this server.";
}
#File: password.txt
#account1,password1
#account2,password2
#account3,password3