+----+----------+----------+-------+-----------------+
| id | nickname | password | socks | favorite_number |
+----+----------+----------+-------+-----------------+
| 1 | Cowlick | salty | 0 | 4 |
| 2 | andy | bandy | 3 | 7 |
+----+----------+----------+-------+-----------------+
####
#!/usr/bin/perl -w
use warnings;
use strict;
use DBI;
my $dsn = 'DBI:mysql:test:localhost';
my $db_user_name = '';
my $db_password = '';
my ($id, $password);
my $dbh = DBI->connect($dsn, $db_user_name, $db_password);
my $input_nickname = 'Cowlick';
my $input_password = 'salty';
my $sth = $dbh->prepare( qq/select id, password from users
where nickname = '$input_nickname'/);
$sth->execute();
($id, $password) = $sth->fetchrow_array();
$sth->finish();
if ($input_password eq $password)
{
print "\nLogin Successful!\n";
print "Here are the stats:\n";
print "="x20,"\n";
print "id = $id, nick=$input_nickname, pass = $password\n";
}
$dbh->disconnect();
####
my $sth = $dbh->prepare( qq/select * from users/);
####
my $sth = $dbh->prepare( qq/select id, password from users where nickname = '$input_nickname'/);