CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Help!

 



dckid
Deleted

Mar 25, 2001, 1:05 PM

Post #1 of 2 (272 views)
Help! Can't Post

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...




wickedxter
User

Mar 26, 2001, 6:49 PM

Post #2 of 2 (263 views)
Re: Help! [In reply to] Can't Post

for one thing... make sure your opening the right file..
you might wanna replace " test.txt " with " passfile.csv "


open (FILE,"test.txt") || die "Can't Open passfile.csv: $!\n";
@LINES=<FILE>;
close(FILE);
foreach $record (@LINES) {
chomp $record;

hope this works!


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives