Beyond the Basics |
Some help on a confirmation loop? |
Christopher
Moderator
Member Rara Avis
since 1999-08-02
Posts 8296Purgatorial Incarceration |
http://egowhores.com/linkage/ - leads to a simple form with a simple user name / password login script (look familiar Ron?) Username: "Cristi" / Password: "cristi". It passes the info ("userName" & "password") to http://egowhores.com/cgi-bin/pl/plink.pl and tries to verify the password as being correct. To all appearances, it checks them and matches them... but it doesn't? I am completely lost here, a little help would be muchly appreciated. The applicable snippet of code: if ($action eq "login") { #Verify Username and Password open (HANDLE, "<db/users.db") || die "Can't open db/users.db: $!\n\n"; @index = <HANDLE>; close (HANDLE); foreach $line (@index) { ($usrNm, $pwd) = split(/\|/, $line); if ($usrNm eq $userName) { chomp($pwd); last; } }#End foreach if ($pwd eq $password) { header(); print qq~yep~; } else { header(); print qq~nope, didn't work<br>$userName<br>$password<br>$usrNm<br>$pwd~; } }#End elsif action = login clause. |
||
© Copyright 2004 C.G. Ward - All Rights Reserved | |||
Ron
Administrator
Member Rara Avis
since 1999-05-19
Posts 8669Michigan, US |
I don't see anything wrong with the code itself, Chris. The output, however, includes a newline that the code above didn't print (\n after $pwd is printed). That suggests that either your chomp isn't being executed or your data file is double-spaced. Unless you have a really huge database, I would send the header() at the top of the code, then do a print $line through each iteration of the loop. Another thing to try is a regex instead of the chomp; i.e. $line =~ s/\n/!/g; will transform all newlines into bangs so you can see them. Or examine the data in a hex editor? Without seeing your data, that's about the best I can figure. |
||
Ron
Administrator
Member Rara Avis
since 1999-05-19
Posts 8669Michigan, US |
Reading that again, I don't think I was very clear. Approaching the tail-end of a long day. Your second conditional (if $pwd eq $password) is probably failing because your first conditional (if usrNm eq $userName) failed and the chomp didn't get executed. OR one chomp isn't enough because the data is double-spaced. |
||
Christopher
Moderator
Member Rara Avis
since 1999-08-02
Posts 8296Purgatorial Incarceration |
I don't for the life of me understand it... but moving header(); to the top worked. Uhm - to repeat myself... I don't understand it. Thanks Ron. Amazing how it always seems to be a really easy thing. |
||
⇧ top of page ⇧ | ||
All times are ET (US). All dates are in Year-Month-Day format. |