Gossamer Forum
Home : Products : DBMan : Customization :

Name in email

Quote Reply
Name in email
hi
i would like to do the following :
In order to use my Dbman, all user have to be registered user.
When user A send a email in the Dbman to user B (sub html_send_email_form), the email user B received would show up like the following:

Hi User B,
User A would like to thanks for all your help....

I dont know how to set the value in the email form like the following coding:
Code:
<input type=hidden name="name" value="$rec{'name'}" size="25" maxlength="255">

i dont want the user A to use the other nick name for sending email to user B. No matter how they email each other in the Dbman..all the name in the email would be the name field that they fill in when adding a record

Any idea how to do the above??
THanks in advance
Smile
Quote Reply
Re: Name in email In reply to
You're using the Private Mailer, right? (I need to make sure we're talking about the same mod.)

At the beginning of sub html_send_email_form, there is the following code:

Code:
$in{$db_key} =~ s/<?.B>//g;
%rec = &get_record($in{$db_key});

At that point, all of the information for the recipient of the email is in the %rec hash and you can use the $rec{'FieldName'} variables there just like you do in sub html_record.

You could then, if you wanted, get the sender's record as well. And put in whatever message you want into the textarea.

Something like this:

Code:
%rec = &get_record($in{$db_key});
%rec2 = &get_record($db_userid);
unless ($in{'emailmessage'}) {
$in{'emailmessage'} = qq|
Hi, $rec{'First Name'},
$rec2{'First Name'} would like to thank you for all your help...
|;
}

This is assuming that your userid is your $db_key field.

For the recipient of the email, use

$rec{'FieldName'}

For the sender of the email, use

$rec2{'FieldName'}

You can put any message you want as a beginning of the email that will go into the textarea.


------------------
JPD






Quote Reply
Re: Name in email In reply to
Cool..
I woud like to know what the different is between $in{$db_key} and $db_userid? because i saw this two weords many times in the Dbman. it would help me to clarify where all the code go to.
Thanks

Quote Reply
Re: Name in email In reply to
I have a stupid question regarding this Smile

How will this function if UserB (sender)

$rec2{'First Name'} using
%rec2 = &get_record($db_userid);

is actually a visitor to the site rather then a logged in user?

Would it just ignore trying to retrieve the sender's name?
Quote Reply
Re: Name in email In reply to
johnsonny, the $db_userid is the login name of the user. The $db_key is the field that you have defined in the .cfg file as the key field for your database. The $in{...} part is a designation for the values that were last sent to the script, either by a form or through a link.

In your case, since you have only one record per user, the $db_key field is the userid field.

In the lines:

%rec = &get_record($in{$db_key});
%rec2 = &get_record($db_userid);

&get_record calls a subroutine that searches for a record based on the value of the $db_key field. In the first line above, the $db_key field value has been sent to the subroutine by a previous action, in order to get the record that belongs to the recipient of the email message. In the second line, the sender of the record is the logged-in user, so we know that the value of the $db_key field for his record is his $db_userid.

Does this make it clearer?

Lois, if a default user is logged in, nothing will be found when &get_record is called, so the %rec2 hash will be empty. In the places where it is referenced, nothing will be entered. (Unless there is a record with the userid of "default" in there, which would not be a good idea.)

It would be a good idea to be sure that this code is used only if you are certain that the person using it is a logged in user. Not that it will cause any real problems, but you might end up with something like:

Hello, John,
wanted to say hi.

It just would look bad.


------------------
JPD






Quote Reply
Re: Name in email In reply to
Thanks for your excellent tutorial
Smile
Quote Reply
Re: Name in email In reply to
hi,
i tried to use the following code in html.pl:
Code:
sub html_send_email_form {
#----------------------------------------------------------
my ($message) = $_[0];
$in{$db_key} =~ s/<?.B>//g;

%rec = &get_record($in{$db_key});
%rec2 = &get_record($db_userid);
unless ($in{'emailmessage'}) {
$in{'emailmessage'} = qq|
Hi, $rec{'name'},
$rec2{'name'} would like to thank you for all your help...
|;
}
.
.
.
But no success.In the email form ,it came up with the following in the textbox:

Hi, johnsonny,
Johnsonny would like to thank you for all your help...

Actually,the sender is "Peter" who wanna sent an email to "johnnsony"..

Any idea??

Thanks Smile

Quote Reply
Re: Name in email In reply to
hi...i still cant figure out how to fix the above problem...

Any help would be greatly appreicated!

Smile
Quote Reply
Re: Name in email In reply to
I don't know. It seems like it should work.

I guess the first debugging we should do is to make sure $db_userid is correct.

Add a line somewhere in sub html_send_email_form -- within a print statement:

<BR>$db_userid is the db_userid<BR>

See if that prints out correctly.


------------------
JPD






Quote Reply
Re: Name in email In reply to
hi...
it came up with the following :

Peter is the db_userid

Peter is the login user (the sender)..however, the following is still in the textbox :

Hi, johnsonny,
johnsonny would like to thank you for all your help...


Again,the sender is "Peter" who wanna sent an email to "johnnsony"..

THanks Smile
Quote Reply
Re: Name in email In reply to
Okay.

For now, comment out the line

%rec = &get_record($in{$db_key});

That is, put a # in front of it so it looks like

#%rec = &get_record($in{$db_key});

See what happens.


------------------
JPD






Quote Reply
Re: Name in email In reply to
 Smile
it came up with the following :

Peter is the db_userid

Hi, Peter,
Peter would like to thank you for all your help...

Peter is the sender (login user)

Quote Reply
Re: Name in email In reply to
Okay. It's getting Peter's record just fine then.

Take out the # from the line that you added last.

Change

%rec2 = &get_record($db_userid);

to

%sender = &get_record($db_userid);

Change

$rec2{'name'} would like to thank you for all your help...

to

$sender{'name'} would like to thank you for all your help...



------------------
JPD








[This message has been edited by JPDeni (edited April 27, 2000).]
Quote Reply
Re: Name in email In reply to
Again, it came up with the following :

Peter is the db_userid

Hi, Peter,
Peter would like to thank you for all your help...

Quote Reply
Re: Name in email In reply to
I will need to see your entire html.pl file. Please copy it to a web-accessible directory (one where you would place .html files) and rename it to html_pl.txt. Then come back here and let me know where to find it.


------------------
JPD






Quote Reply
Re: Name in email In reply to
THanks a lot JPDeni,

http://100daily.hypermart.net/html_pl.txt

P.S : dont worry about some of special character that is chinese
Smile
Quote Reply
Re: Name in email In reply to
This makes no sense at all. I don't know why it is doing this.

You can take out the line

<BR>$db_userid is the db_userid<BR>

Just to see what happens, try swapping the two "get_record" lines.

Code:
%sender = &get_record($db_userid);
%rec = &get_record($in{$db_key});



------------------
JPD






Quote Reply
Re: Name in email In reply to
THanks a lot
It works now!!

By the way, you said the following :
Code:
This makes no sense at all. I don't know why it is doing this.
have i done any mistaken for my DBman ?? If so,could you please point me out??
My Dbman is kind of massive and i have just been adding as much function as possilbe into my DBman before i try to do the real thing like setting all the table, logical...

Anyway..THanks
Smile
Quote Reply
Re: Name in email In reply to
hahhaha...THanks JPDeni,
i think i need to tie up my html.pl. It does look massive.

Smile
Quote Reply
Re: Name in email In reply to
You mean it started working when you swapped the lines? That is bizarre!!!

I don't think you've done anything wrong. I couldn't see anything wrong in your files. I'll admit that I didn't look closely, but everything seemed all right.

I guess if it's working now, that's all that matters, but it's still very strange. Smile


------------------
JPD