Perl and Mysql display data problem

FoRo <[email protected]>
Newsgroups gmane.comp.db.mysql.perl
Message-ID <[email protected]>
Hello I have several problems. I'm trying to write a perl script that would
check the username and password from Mysql database and allow users to
login. I'm new to both systems and i have a lot of oruble with them. Here is
the perl script that i'm trying to build.
-----------------------------------------------------------------------------------------------------

#!/usr/bin/perl -wT

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_name, $db_password);


my ($sth);


my ($input_username = "bobob", $input_password = "password") 


my $sth = $dbh->prepare(qq{
   select uid, password from logins
        where username = $input_username
});
$sth->execute();

($uid, $password) = $sth->fetchrow_array();
$sth->finish(): 
if ($input_password eq $password) 
{
          ...
}

$sth->fetchrow_array()

my $sth = $dbh->prepare(qq{
   select fname, lname from users
});
$sth->execute();
while (my ($fname, lname) = 
  $sth->fetchrow_array())
{
     print "$fname, $lname\n";
}
$sth->finish();
 

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


$dbh->disconnect();

-----------------------------------------------------------------------------------------------------

I keep on getting this errors, i have idea how to fix them. :)

-----------------------------------------------------------------------------------------------------

syntax error at ./login.pl line 34, near ")


my "
Global symbol "$input_username" requires explicit package name at ./login.pl
line 34.
Global symbol "$uid" requires explicit package name at ./login.pl line 40.
syntax error at ./login.pl line 41, near "):"
Execution of ./login.pl aborted due to compilation errors.

-----------------------------------------------------------------------------------------------------


Any help would be really apreciated.

Another question i have, how to write the code so it could get for example
first name and last name. and put them in to a hashed array, so i could
display only fthe first or last name on the page.

Once again, thx guys.

--
View this message in context: http://www.nabble.com/Perl-and-Mysql-display-data-problem-t1842429.html#a5029478
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.