|
Assigning values from database to a hash or an array.: msg#00022db.mysql.perl
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/perl?unsub=gcdmp-msql-mysql-modules@xxxxxxxxxxx |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Perl and Mysql display data problem: 00022, Martin MC Brown |
|---|---|
| Next by Date: | compiling DBD-mysql: 00022, Wagner, Chris (GEAE, CBTS) |
| Previous by Thread: | Perl and Mysql display data problemi: 00022, FoRo |
| Next by Thread: | compiling DBD-mysql: 00022, Wagner, Chris (GEAE, CBTS) |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |