#!/usr/local/bin/perl -w #----------------------------------------------- # Login version 4 # # Purpose: Receive username and password through # CGI, and verifies them with a list of usernames # and passwords. Prints whether the user is # verified. # The same as login3.cgi, but uses a separate # password file rather than storing the password # in the script itself. # # Author: H.L. Hiew # Created: 10/07/2000 # Last modified: 10/08/2001 # #----------------------------------------------- use CGI qw(:standard) ; # get the user-supplied name and passwd from CGI my $username = param("name") ; my $passwd = param("passwd") ; # open the password file for reading open(PWFILE, ") { @file_contents = split(/\n/) ; foreach $line (@file_contents) { ($usr, $pw) = split(/;/,$line) ; if (($usr eq $username) && ($pw eq $passwd)) { $verified = 1 ; } } } close(PWFILE) ; # print the values as HTML document print <

Login Page version 4


$username is END # print the word "verified" or "not verified." if ($verified) { print "verified." ; } else { print "not verified." ; } # Print the remaining HTML tags print < END