in reply to username and password verification from a table in Postgres
use Digest::MD5 qw(md5); # ... assume that $dbh was initialize previously ... my $query = qq(SELECT count(*) FROM user WHERE username=? AND password +=?); my $sth = $dbh->prepare($query); $sth->execute($user,md5($password)); ($rc) = $sth->fetchrow_array; if( $rc == 1 ) { # user and pass matched } else { # user and pass did not match (rc == 0 ) or # you don't have a unique key for user/pass (rc > 1) }
|
|---|