Gossamer Forum
Home : Products : DBMan SQL : Discussion :

Private Mailer Mod Question

Quote Reply
Private Mailer Mod Question
I started with the flat-file version of dbman and have gone to the SQL version. I am using the User-friendly html.pl

I am using the database as an alumni contact database.

I have implemented the Private Mailer mod and here is what I am trying to do... I want the logged in user to be able to send an email to any of the users in the database that they choose. However, in the Private mailer mod it asks for the sender to enter their email address... I do not want to give them the option to add their email address.

I want their email address (sender) to be passed as a hidden variable

Any ideas on how to accomplish this?

donm
Quote Reply
Re: [donm] Private Mailer Mod Question In reply to
It's no easy job on this feature. We can do it as custom job, please contact me via email if you're interested.

TheStone.

B.
Quote Reply
Re: [TheStone] Private Mailer Mod Question In reply to
I should have added that we have everything working in MySQL. Everything has been changed in our User-friendly html.pl to accommodate the SQL version and has been working for quite awhile. The private mailer mod is also working without any problems at all.

I just do not want the user to be able to enter an email address any longer as they sometimes will enter a bogus email. I want the send_email_html sub to dynamically pull the senders email address and send the email to the user.

I know how to pull the db_userid of the logged in user - I need to pull in the record of the logged in user in order to get their email address in order to display it. This is what I need to know how to do?

donm
Quote Reply
Re: [donm] Private Mailer Mod Question In reply to
You could just query the user table for the email addy as long as there is a field for it. You could add this:

After:

if ($message) { print qq|<font color="red">There was a problem: $message</font>|; }
print qq|
<$font>Fill in your email address, the subject of your email and the
message you wish to send to $Playername.</font>
|;

Add:

my $username_q = $DBH->quote($db_userid);

$query = qq!
SELECT Email FROM $db_table_user
WHERE username = $username_q
!;
my $sth = $DBH->prepare($query);
$sth->execute();
if ($sth->rows) {
while (@data = $sth->fetchrow_array) {
$email = $data[3]; # change to correct field number for email
}
}

$sth->finish;

Then replace:

<td><input type=text name="email" value="$in{'email'}" size=40></td></tr>


with:

<td><input type=hidden name="email" value="$email" size=40></td></tr>


I haven't tested this, but it should work without any other changes.


DBMan SQL Version 1 mods available at:
http://dbmansqlmods.rainbowroomies.com
(Mods based on JPDeni's original mods.)
Quote Reply
Re: [shann123] Private Mailer Mod Question In reply to
Shann thanks for your help!

When I try this - I receive the following error:

Error Message : fatal error: Can't call method "quote" on an undefined value at ./html.pl line 3621.

donm
Quote Reply
Re: [donm] Private Mailer Mod Question In reply to
OK.. had to try it out on my website... here's what I did to get it to work.

Before the first print qq|

Add:

my $username_q = $DBH->quote($db_userid);

$query = qq!
SELECT * FROM $db_table_user
WHERE username = $username_q
!;
my $sth = $DBH->prepare($query);
$sth->execute();
if ($sth->rows) {
while (@data = $sth->fetchrow_array) {
$Email = $data[2]; # change to the correct field number
}
}

Then change

<table><tr><td align=right><$font>Your email address:</font></td>
<td><input type=text name="email" value="$in{'Email'}" size=40></td></tr>

To:

<table><tr><td align=right><$font>Your email address:</font></td>
<td><input type=hidden name="email" value="$Email"></td></tr>

To hide the whole field, change this:

<input type=hidden name="$db_key" value="$in{$db_key}">
<table><tr><td align=right><$font>Your email address:</font></td>
<td><input type=text name="email" value="$in{'Email'}" size=40></td></tr>


To:

<input type=hidden name="$db_key" value="$in{$db_key}">
<input type=text name="email" value="$Email">
<table>


That just adds the hidden with the other hidden inputs. Smile


DBMan SQL Version 1 mods available at:
http://dbmansqlmods.rainbowroomies.com
(Mods based on JPDeni's original mods.)