dbTalk Databases Forums  

A very easy mysql problem

mailing.database.msql-mysql-modules mailing.database.msql-mysql-modules


Discuss A very easy mysql problem in the mailing.database.msql-mysql-modules forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Unternährer Thomas, uth
 
Posts: n/a

Default A very easy mysql problem - 10-02-2003 , 02:31 AM







I want to compare the password, which the user typed in (in a textfield) =
with a password, which is in a MySQL-db.

I tried the following:


=09my $dbh =3D db_open("mypoll300903", "testuser", "authmysql");
=09my $sth =3D $dbh->prepare("select password from table1 where prename =3D=
=20\"testprename\" and name =3D \"testname\";")
=09 or die ($dbh->errstr);
=09$sth->execute or die $sth->errstr;
=09print "$sth";=09
=09$dbh->disconnect();=20

$sth is not yet what I want. It is something like the structure of what I=
=20need.

=09I'd like to do the following:

=09if ($passdb es $passusr) { ## $passdb =3D the transformed $sth=20
=09 $OK =3D 1;
=09}



Any help will be greatly appreciated,

Thomas



Content Security by MailMarshal

--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=3D...ie.nctu.edu.tw


Reply With Quote
  #2  
Old   
Aleksey Kishkin
 
Posts: n/a

Default Re: A very easy mysql problem - 10-03-2003 , 04:27 AM






Unternährer Thomas wrote:
Quote:
I want to compare the password, which the user typed in (in a textfield)
with a password, which is in a MySQL-db.

I tried the following:


my $dbh = db_open("mypoll300903", "testuser", "authmysql");
my $sth = $dbh->prepare("select password from table1 where prename =
\"testprename\" and name = \"testname\";")
or die ($dbh->errstr);
$sth->execute or die $sth->errstr;
print "$sth";
$dbh->disconnect();

$sth is not yet what I want. It is something like the structure of what I need.

After execution you must retrieve result records. Common way is:
my @record;
while ( @record = $sth->fetchrow_array() )
{
# here we have a result record in @record
}

But as far as you expect only one record with only one field, you can perform
it this way:

my $dbh = db_open("mypoll300903", "testuser", "authmysql");
my $sth = $dbh->prepare("select password from table1 where
prename = \"testprename\" and name = \"testname\";")
or die ($dbh->errstr);
$sth->execute or die $sth->errstr;
my $userpassword = $sth->fetchrow_array(); # in scalar context
# fetchrow_array returns
# first field
if ( defined($userpassword) )
{
# compare password as you wanted
} else {
print "Nobody found";
}

$dbh->disconnect();



--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=ms...ie.nctu.edu.tw



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.