navwin » Tech Talk » Beyond the Basics » Some help on a confirmation loop?
Beyond the Basics
Post A Reply Post New Topic Some help on a confirmation loop? Go to Previous / Newer Topic Back to Topic List Go to Next / Older Topic
Christopher
Moderator
Member Rara Avis
since 1999-08-02
Posts 8296
Purgatorial Incarceration

0 posted 2004-02-02 11:08 PM


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 8669
Michigan, US
1 posted 2004-02-02 11:38 PM


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 8669
Michigan, US
2 posted 2004-02-02 11:45 PM


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 8296
Purgatorial Incarceration
3 posted 2004-02-02 11:57 PM


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.

Post A Reply Post New Topic ⇧ top of page ⇧ Go to Previous / Newer Topic Back to Topic List Go to Next / Older Topic
All times are ET (US). All dates are in Year-Month-Day format.
navwin » Tech Talk » Beyond the Basics » Some help on a confirmation loop?

Passions in Poetry | pipTalk Home Page | Main Poetry Forums | 100 Best Poems

How to Join | Member's Area / Help | Private Library | Search | Contact Us | Login
Discussion | Tech Talk | Archives | Sanctuary