
dckid
Deleted
Mar 25, 2001, 1:05 PM
Post #1 of 2
(293 views)
|
I hope nobody objects to cries for help like this, but i've tried everywhere else I can think of. Can anyone see what is wrong with this code? It complains that the CSV file does not exist, when it does, and in the same directory as the script...#!d:\perl\bin\perl.exe $username; $password; $inputusername; $inputpassword; if ($ENV{'REQUEST_METHOD'} eq 'POST') {read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @cgiPairs = split(/&/,$buffer); foreach $cgiPair (@cgiPairs) { ($name,$value) = split(/=/,$cgiPair); $value =~ s/\+/ /g; $value =~ s/%(..)/pack("c",hex($1))/ge; $form{$name} .= "\0" if (defined($form{$name})); $form{$name} .= "$value"; } } $inputusername = $form{'username'}; chomp $inputusername; $inputpassword = $form{'password'}; chomp $inputpassword; #open the password file open (FILE,"test.txt") || die "Can't Open passfile.csv: $!\n"; @LINES=<FILE>; close(FILE); foreach $record (@LINES) { chomp $record; @file_array = split(/\,/,$record); if (($inputusername eq $file_array[0]) && ($inputpassword eq $file_array[1])) {&allow;} } &deny; sub deny{ print "Content-type: text/html\n\n"; print "<html><head><title>Log in failure</title></head>\n"; print "<body bgcolor=#FFFFFF>\n"; print "Login Failed. \n"; print "Please try again. \n"; print "</body></html>"; exit;} sub allow{ print "Content-type: text/html\n\n"; print "<html><head><title>Welcome</title></head>\n"; print "<body bgcolor=#FFFFFF>\n"; print "Please select an option: \n"; print "<FORM METHOD='POST' ACTION='project1.cgi'> \n"; print "<input type='submit' value='Addrecord' name='Add a record'> \n"; print "</form>\n"; print "</body></html>"; exit;} If anyone can help i'd be very happy! Thanx...
|