in reply to How to check if successfully logged in?
sub authenticate { my $username = shift; my $password = shift; return 0 unless $username && $password; my $dbh = DBI->connect("DBI:mysql:[DATABASE NAME]:[HOSTNAME]" "*****", "*****", { RaiseError => 1 }) or die + $DBI::errstr; my $sth = $dbh->prepare("SELECT id from table WHERE name = ? AND pass = ? LIMIT 1"); $sth->execute($username, $password); my ( $id ) = $sth->fetchrow_array(); $dbh->disconnect; return ($id) ? 1 : 0 }
|
|---|