Gossamer Forum
Home : Products : DBMan SQL : Discussion :

sub get_email conversion

Quote Reply
sub get_email conversion
I am really stuck on converting Secure Password Lookup Mod. I hit the sub get_email and it's like a brick wall.

Anyone have a conversion for sub get_email for dbmanSQL?



Quote Reply
Re: sub get_email conversion In reply to
That Mod is incompatible because it uses OPEN codes to access flat files versus accessing MySQL database and the User table.

I would recommend looking through the original db.cgi and try copying codes for accessing your MySQL database.

Regards,

Eliot Lee
Quote Reply
Re: sub get_email conversion In reply to
I would think using a "SELECT ...WHERE ...FROM" command would do the trick but I'm not savvy enought to come up with the exact coding and assign the results to the $rec{'Email'} variable.

Thanks for your suggestion but I think trying to access a MySQL file via the Perl OPEN command would be even trickier.



Quote Reply
Re: sub get_email conversion In reply to
Uh...MySQL is a database NOT a flat file...have to change your thinking with DBMAN SQL.

Regards,

Eliot Lee
Quote Reply
Re: sub get_email conversion In reply to
It took awhile but if anyone is interested here's a conversion of sub get_email for dbmanSQL:



sub get_email {
# --------------------------------------------------------
# Pulls the email address from the password file.


my ($message, $userid, $pw, $view, $add, $del, $mod, $admin, $addr,
$password, $found, $output, $pass);
my $username_q = $DBH->quote($in{'userid'});
my $addr_q = $DBH->quote($in{'addr'});
$query = qq! SELECT addr FROM $db_table_user WHERE username = $username_q !;
my $sth = $DBH->prepare ($query) or &cgierr("Unable to query database. Reason: $DBI::errstr. Query: $query");
$sth->execute or &cgierr("Unable to query database. Reason: $DBI::errstr. Query: $query");
if ($sth->rows) {
my (@data, $username, $pw, $email);
while (@data = $sth->fetchrow_array) {
$addr = $data[0];
}
}
$sth->finish;
$rec{'email'}=$addr;
}