Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I am working on a logon script for a web applicaton. I am trying to create a clause whereby if the correct username and password are entered proceed to the next page, but if a wrong username is entered give an error, or if the wrong password is entered give an error, and as that hasn't seemed to suffice, if a correct username but wrong password is entered give and error and visa versa.
Below is the code i have been testing, it works for all occurrances except where a correct username is entered with a wrong password or via versa, in this case i get an internal server error, instead of my own specified error.
Can anybody see what I am doing wrong? Thanks#after reading in the values if($username eq "" || $hashPassword == $null) { error(); }else{ #after comparing them to the actual passwords stored in $sth = $db->prepare(q{SELECT userid, password from user where userid = + ?}) or die("usr prepare error: $!"); $usr->execute($username) or die("usr prepare error: $!"); while(@row = $sth->fetchrow_array){ if($username eq $row[0] && $hashPassword eq $row[1]) { #Go to the new page }elsif($username ne $row[0] || $hashPassword != $row[1]) { error(); }elsif($username eq $row[0] && $hashPassword != $row[1]) { error(); }elsif($username ne $row[0] && $hashPassword == $row[1]) { error(); }elsif($username ne $row[0] && $hashPassword != $row[1]) { error(); } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: elsif loop
by liverpole (Monsignor) on Dec 12, 2006 at 14:26 UTC | |
Re: elsif loop
by jbert (Priest) on Dec 12, 2006 at 14:35 UTC | |
Re: elsif loop
by tinita (Parson) on Dec 12, 2006 at 14:46 UTC | |
by Anonymous Monk on Dec 12, 2006 at 15:55 UTC | |
by nimdokk (Vicar) on Dec 12, 2006 at 17:26 UTC | |
Re: elsif loop
by blue_cowdawg (Monsignor) on Dec 12, 2006 at 14:26 UTC |
Back to
Seekers of Perl Wisdom