if ($sth->selectrow_array('SELECT COUNT(*) FROM '.$Tablename. 'WHERE username = 0x'.unpack('H*',$uname). ' AND password = 0x'.unpack('H*',$pword))) { # Successful login } else { # Oops, something failed } #### SELECT COUNT(*) FROM users WHERE username = 0x75736572 AND password = 0x313233 #### my ($UserID,$UserState) = $sth->selectrow_array('SELECT ID,State FROM '.$Tablename. 'WHERE username = 0x'.unpack('H*',$uname). ' AND password = 0x'.unpack('H*',$pword)); if ( ! defined($UserID)) { # Oops, no UserID means no user with matching username/password was found } elsif ($UserState eq 'LOCKED') { # Oops, this user is not allowed to login } else { # ok, everything right, the user is validated }