Assigning values from database to a hash or an array.

FoRo <[email protected]>
Newsgroups gmane.comp.db.mysql.perl
Message-ID <[email protected]>
Here is my question. 
when i connect to a database how can i assign values from table that
contains user_id, and user_password fields to a hash or an array or a hashed
array?

for example i have this script.

my ($input_username,$input_password) = ("bobob","pass");



$sth = $dbh->prepare("select password from logins where
username='$input_username'");
$sth->execute();
($password) = $sth->fetchrow_array();
$sth->finish();
if ($input_password eq $password)
{

***Now, how can i put the staintmentso when it's trye transfer me to a
members.pl file?

} 
else
{
print "Wrong Password";<------- Do i really have to type anything here?
}

How can i get values from database called ttf, table logins, and get the
user_id and user_password. and assign them to the array?
I have tryed this, but it's not working.

my (@details) = ();
while (my @ary = sth->fetchrow_array())
{
push(@matrix, [@array]);
}
sth->finish();


Later on i just need to display to user id and users password using those
variables.

Thank you.



Here is the full script.

use  strict;
use  CGI;
use  CGI::Carp;
use  DBI;
use  Template;

# Load the CGI input data, 
my $html = new CGI;
print $html->header();


my $dsn = 'DBI:mysql:ttf:localhost';
my $db_user_name = 'web';
my $db_password = 'nouser';
my ($uid, $password);
my $dbh = DBI->connect($dsn,  $db_user
my ($sth);
my ($input_username,$input_password) = ("bobob","pass");



$sth = $dbh->prepare("select password from logins where
username='$input_username'");
$sth->execute();
($password) = $sth->fetchrow_array();
$sth->finish();
if ($input_password eq $password)
{
print "Good"
} 
else
{
print "Wrong Password";
}

my (@details) = ();
while (my @ary = sth->fetchrow_array())
{
push(@matrix, [@array]);
}
sth->finish();
$dbh->disconnect();

any help would be appreciated.
--
View this message in context: http://www.nabble.com/Assigning-values-from-database-to-a-hash-or-an-array.-t1846634.html#a5040539
Sent from the MySQL - Perl forum at Nabble.com.


-- 
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe:    http://lists.mysql.com/[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.