|
Re: Perl and Mysql display data problem: msg#00019db.mysql.perl
Hello, I'm pretty experienced with using Perl and MySQL. Its what I do to build my web applications. For a authentication scheme, you may want to always check the username and password input. First do username and password validation before even calling mysql. For example, if your password supposed to have a minimum of 6 characters, then validate that before you connect to your MySQL database. Also, you should look into using MD5 for your password column for your user database. As for your Perl Syntax problem....perhaps chang this part of your coding: ($uid, $password) = $sth->fetchrow_array(); $sth->finish(): #<---CHANGE : to ; if ($input_password eq $password) { ... } ----- Original Message ----- From: "FoRo" <foroz@xxxxxxxxxx> To: <perl@xxxxxxxxxxxxxxx> Sent: Saturday, June 24, 2006 6:15 PM Subject: Perl and Mysql display data problem > 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/perl?unsub=Anthony.Tang@xxxxxxxxxxxxxxxxxxxxxxxxxx > > > > > > -- > No virus found in this incoming message. > Checked by AVG Free Edition. > Version: 7.1.394 / Virus Database: 268.9.3/374 - Release Date: 6/23/2006 > > |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Perl and Mysql display data problem: 00019, Darren Duncan |
|---|---|
| Next by Date: | Re: Perl and Mysql display data problem: 00019, Martin J. Evans |
| Previous by Thread: | Re: Perl and Mysql display data problemi: 00019, Darren Duncan |
| Next by Thread: | Re: Perl and Mysql display data problem: 00019, Martin J. Evans |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |