Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl/DBI username searching problem

Status
Not open for further replies.

dreamstreet

Programmer
Joined
Jan 24, 2003
Messages
25
Location
US
Hello,

I'm trying to check if the username and password that is entered through the URL query by the user is correct. Now the URL goes : login.cgi?username=$username&pass=$pass&step=pg1

When I move on to the 'pg1' subroutine, I want to make sure if the entered username/password is correct. So I did the following but it doesn't seem to work:

sub pg1 {
&check_username;

print 'blah...
}


sub check_username {

$sql = <<EOF;
select * from members
EOF

my $sth = $dbh->prepare("$sql") or print "SQL ERROR";
$sth->execute();
while (@row = $sth->fetchrow() ) {

if (param('username') eq "$row[1]" && param('pass') eq "$row[2]") {
$id=$row[0];
$username=$row[1];
$pass=$row[2];
$email=$row[3];

}
print "Invalid Username/Pass";
exit;
}

ANy idea? Thanks for reading. I appreciate it.
}
 
First off, its insecure to pass username and password information in a GET request, you should use POST
try this

Code:
print "User:".param('username')."=>".$row[1];
print "Pass:".param('pass')."=>".$row[2];
if ((param('username') eq "$row[1]") &&  (param('pass') eq "$row[2]")) {
Note the extra braces on the if statement
HTH
--Paul

cigless ...
 
Paul, that was beautiful :P Happy Easter
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top