Unternährer Thomas wrote:
Quote:
I want to compare the password, which the user typed in (in a textfield)
with a password, which is in a MySQL-db.
I tried the following:
my $dbh = db_open("mypoll300903", "testuser", "authmysql");
my $sth = $dbh->prepare("select password from table1 where prename =
\"testprename\" and name = \"testname\";")
or die ($dbh->errstr);
$sth->execute or die $sth->errstr;
print "$sth";
$dbh->disconnect();
$sth is not yet what I want. It is something like the structure of what I need. |
After execution you must retrieve result records. Common way is:
my @record;
while ( @record = $sth->fetchrow_array() )
{
# here we have a result record in @record
}
But as far as you expect only one record with only one field, you can perform
it this way:
my $dbh = db_open("mypoll300903", "testuser", "authmysql");
my $sth = $dbh->prepare("select password from table1 where
prename = \"testprename\" and name = \"testname\";")
or die ($dbh->errstr);
$sth->execute or die $sth->errstr;
my $userpassword = $sth->fetchrow_array(); # in scalar context
# fetchrow_array returns
# first field
if ( defined($userpassword) )
{
# compare password as you wanted
} else {
print "Nobody found";
}
$dbh->disconnect();
--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=ms...ie.nctu.edu.tw