Gossamer Forum
Home : Products : DBMan : Customization :

Forward Record Mod Help

Quote Reply
Forward Record Mod Help
I would line to add 3 new form fields to the submission form in the "FORWARD RECORD MOD"
1. Full name
2. Company
2. Country

However when i add the 3 fields in the DB.CGI and the HTML.PL and submit the form it gives the impression that the submission was successfull saying "Your email message was sent"
HOWEVER the email is NOT received by the recipient.

Can someone tell me what I am doing wrong and What to do to add these additional fields

**below are the changes I made to the DB.CGI and Html.pl**

sub forward_email {
# --------------------------------------------------------
# This subroutine added foward record mod
#
unless ($in{'yourname'}) { $message .= "You must fill in your full name<BR>"; }
unless ($in{'company'}) { $message .= "You must fill in your company name<BR>"; }
unless ($in{'country'}) { $message .= "You must fill in your country where you live<BR>"; }
unless ($in{'email'}) { $message = "You must fill in your email address<BR>"; }
unless ($in{'email'} =~ /.+\@.+\..+/) { $message = "Your email address is not in the correct format.<BR>"; }
unless ($in{'to_email'}) { $message = "You must fill in the recipient's email address<BR>"; }
unless ($in{'to_email'} =~ /.+\@.+\..+/) { $message = "The recipient's email address is not in the correct format.<BR>"; }
unless ($in{'subject'}) { $message .= "You must fill in a subject for your message.<BR>"; }
unless ($in{'emailmessage'}) { $message .= "Your email message is empty.<BR>"; }
if ($message) {
chomp($message);
&html_forward_email_form($message);
return;
}
open (MAIL, "$mailprog") || &cgierr("unable to open mail program");
print MAIL "Full Name: $in{'yourname'}\n";
print MAIL "Company: $in{'company'}\n";
print MAIL "Country: $in{'country'}\n";
print MAIL "To: $in{'to_email'}\n";
print MAIL "From: $in{'email'}\n";
print MAIL "Subject: $in{'subject'}\n\n";
print MAIL "-" x 75 . "\n\n";
print MAIL $in{'emailmessage'};
close (MAIL);
&html_forward_email_success;
}






In the HTML.PL I added the the 3 to fields

sub html_forward_email_form {
#----------------------------------------------------------
my ($message) = $_[0];
$in{$db_key} =~ s/<?.B>//g;
%rec = &get_record($in{$db_key});
unless ($in{'email_message'}) {
foreach $col (@db_cols) {
$in{'email_message'} .= "$col: $rec{$col}\n";
}
}
&html_print_headers;
print qq|
<html><head><title>$html_title: Email Enquiry</title></head>
<body bgcolor="#DDDDDD">
<center>
<table border=1 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=500 align=center valign=top>
<tr><td colspan=2 bgcolor="navy">
<FONT FACE="MS Sans Serif, arial,helvetica" size=1 COLOR="#FFFFFF">
<b>$html_title: Email Enquiry</b></td></tr>
<tr><td>
<p><center><$font_title><b>
Enquire About This Vehicle
</b></font></center><br>
|;
if ($message) { print qq|There was a problem: $message|; }
print qq|
<$font>Use the <b>recipient field</b> to send a copy to yourself or to your client. If sending to us for enquiry, please copy "seicars\@gmail.com" in the field and your message in the message box $rec{'Name'}.</font>
|;
print qq|
<form action="$db_script_url" method="POST">
<input type=hidden name="db" value="$db_setup">
<input type=hidden name="uid" value="$db_uid">
<input type=hidden name="$db_key" value="$in{$db_key}">
<table><tr><td align=right><$font>Full Name:</font></td>
<td><input type=text name="yourname" value="$in{'yourname'}" size=40></td></tr>
<tr><td align=right><$font>Company:</font></td>
<td><input type=text name="company" value="$in{'company'}" size=40></td></tr>
<tr><td align=right><$font>Country:</font></td>
<td><input type=text name="country" value="$in{'country'}" size=40></td></tr>
<tr><td align=right><$font>Your email address:</font></td>
<td><input type=text name="email" value="$in{'email'}" size=40></td></tr>
<tr><td align=right><$font>Recipient's email address:</font></td>
<td><input type=text name="to_email" value="$in{'to_email'}" size=40></td></tr>
<tr><td align=right><$font>Subject:</font></td>
<td><input type=text name="subject" value="$in{'subject'}" size=40></td></tr>
<tr><td align=right><$font>Your message:</font></td>
<td><textarea name="emailmessage" cols=40 rows=6 wrap="virtual">$in{'email_message'}</TEXTAREA></td></tr>
</table>
<center>
<INPUT TYPE="SUBMIT" NAME="forward_email" VALUE="Send Record">
<INPUT TYPE="RESET" VALUE="Reset Form">
</center>
</form>
|;
&html_footer;
print qq|</td></tr></table></body></html>|;
}
###############################################################################
#file: html.pl #
# new subroutine #
# sub html_forward_email_success #
###############################################################################
sub html_forward_email_success {
#-----------------------------------------------
&html_print_headers;
print qq|
<html><head><title>$html_title: Send An Enquire</title></head>
<body bgcolor="#DDDDDD">
<center>
<table border=1 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=500 align=center valign=top>
<tr><td colspan=2 bgcolor="navy">
<FONT FACE="MS Sans Serif, arial,helvetica" size=1 COLOR="#FFFFFF">
<b>$html_title: Send An Enquire</b></td></tr>
<tr><td><p><center><$font_title><b>
Send An Enquire
</b></font></center><br>
|;

print qq|<$font>Your email message was sent.</font><P>
<center>
<a href="$db_script_link_url&$db_key=$in{$db_key}&view_records=1">
<$font>Go back to the record</font></a></center>|;

&html_footer;
print qq|</td></tr></table></body></html>|;
}
Quote Reply
Re: [jamaicasearch41] Forward Record Mod Help In reply to
 
The first question I have to ask is, did you test it out after you installed the mod, but before you added the other fields? If you did, and it worked, then your addition of the fields is the source of the problem. If you didn't, I would suggest you take out your modifications and give it a try. If it works, put your stuff back in and try again. If it doesn't work, let's find out why. :-)


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [JPDeni] Forward Record Mod Help In reply to
Hi JPDeni

Thanks for replying, yes i tested it all possible ways....it works perfectly without the additional fields...i even tried one additional field at a time but the recipient never receives the email sent....and the script does not crash either when the new fields are added it say the submission was sucessfully.

Could it be that the sendmail script from my hosting does not support those additional "named" fields?

unless ($in{'yourname'}) { $message .= "You must fill in your full name<BR>"; }
unless ($in{'company'}) { $message .= "You must fill in your company name<BR>"; }
unless ($in{'country'}) { $message .= "You must fill in your country where you live<BR>"; }

I have set up a sample database with both examples:

http://www.seicars.com/...forward_email_form=1

http://www.seicars.com/...forward_email_form=1


Please help me here
Quote Reply
Re: [jamaicasearch41] Forward Record Mod Help In reply to
Try printing out your fields just before you print out the email message. sendmail requires the header data to be entered in a certain way. And it doesn't often give error messages. It just doesn't send stuff if it's not in the right format.


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.

Last edited by:

JPDeni: Mar 20, 2005, 2:51 PM
Quote Reply
Re: [JPDeni] Forward Record Mod Help In reply to
Hi JPDeni,

Thanks very much, it worked like a charm, you can test it yourself at the link i sent earlier

thank u sooooooooooooooo much you are an angel
Everton
Quote Reply
Re: [jamaicasearch41] Forward Record Mod Help In reply to
Yay!! I did test it and it did work. Yippee!! :-D

You're very welcome.


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [JPDeni] Forward Record Mod Help In reply to
Hi JPDENI,

I am sorry to be bugging you again, How can I have the Forward Record Form just be dedicated to sending the email to the administrator.

So I would like to hard code the administrators email address in the recipients field then hide the field from the user.

So i am taking away the forms ability to send to a friend.

Below are related extracts from my html, db.cgi, and default.cfg


HTML:-
..................

sub html_forward_email_form {
#----------------------------------------------------------
my ($message) = $_[0];
$in{$db_key} =~ s/<?.B>//g;
%rec = &get_record($in{$db_key});
unless ($in{'email_message'}) {
foreach $col (@db_cols) {
$in{'email_message'} .= "$col: $rec{$col}\n";
}
}
&html_print_headers;
print qq|
<html><head><title>$html_title: Email Enquiry</title></head>
<body bgcolor="#DDDDDD">
<center>
<table border=1 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=500 align=center valign=top>
<tr><td colspan=2 bgcolor="navy">
<FONT FACE="MS Sans Serif, arial,helvetica" size=1 COLOR="#FFFFFF">
<b>$html_title: Email Enquiry</b></td></tr>
<tr><td>
<p><center><$font_title><b>
Enquire About This Vehicle
</b></font></center><br>
|;
if ($message) { print qq|There was a problem: $message|; }
print qq|
<$font> $rec{'Name'}.</font>
|;
print qq|
<form action="$db_script_url" method="POST">
<input type=hidden name="db" value="$db_setup">
<input type=hidden name="uid" value="$db_uid">
<input type=hidden name="$db_key" value="$in{$db_key}">
<table><tr><td align=right><$font>Full Name:</font></td>
<td><input type=text name="yourname" value="$in{'yourname'}" size=40></td></tr>
<tr><td align=right><$font>Company:</font></td>
<td><input type=text name="company" value="$in{'company'}" size=40></td></tr>
<tr><td align=right><$font>Country:</font></td>
<td><input type=text name="country" value="$in{'country'}" size=40></td></tr>
<tr><td align=right><$font>Your email:</font></td>
<td><input type=text name="email" value="$in{'email'}" size=40></td></tr>
<tr><td align=right><$font>Recipient's email:</font></td>
<td><input type=text name="to_email" value="$in{'to_email'}" size=40></td></tr>
<tr><td align=right><$font>Subject:</font></td>
<td><input type=text name="subject" value="$in{'subject'}" size=40></td></tr>
<tr><td align=right><$font>Your message:</font></td>
<td><textarea name="emailmessage" cols=40 rows=6 wrap="virtual">$in{'email_message'}</TEXTAREA></td></tr>
</table>
<center>
<INPUT TYPE="SUBMIT" NAME="forward_email" VALUE="Send Record">
<INPUT TYPE="RESET" VALUE="Reset Form">
</center>
</form>
|;


My DB.CGI
......................

sub forward_email {
# --------------------------------------------------------
# This subroutine added foward record mod
#
unless ($in{'yourname'}) { $message .= "You must fill in your full name<BR>"; }
unless ($in{'company'}) { $message .= "You must fill in your company name<BR>"; }
unless ($in{'country'}) { $message .= "You must fill in your country where you live<BR>"; }
unless ($in{'email'}) { $message = "You must fill in your email address<BR>"; }
unless ($in{'email'} =~ /.+\@.+\..+/) { $message = "Your email address is not in the correct format.<BR>"; }
unless ($in{'to_email'}) { $message = "You must fill in the recipient's email address<BR>"; }
unless ($in{'to_email'} =~ /.+\@.+\..+/) { $message = "The recipient's email address is not in the correct format.<BR>"; }
unless ($in{'subject'}) { $message .= "You must fill in a subject for your message.<BR>"; }
unless ($in{'emailmessage'}) { $message .= "Your email message is empty.<BR>"; }
if ($message) {
chomp($message);
&html_forward_email_form($message);
return;
}
open (MAIL, "$mailprog") || &cgierr("unable to open mail program");
print MAIL "To: $in{'to_email'}\n";
print MAIL "From: $in{'email'}\n";
print MAIL "Subject: $in{'subject'}\n\n";
print MAIL "-" x 75 . "\n\n";
print MAIL "Full Name: $in{'yourname'}\n";
print MAIL "Company: $in{'company'}\n";
print MAIL "Country: $in{'country'}\n";
print MAIL $in{'emailmessage'};
close (MAIL);
&html_forward_email_success;
}


DEFAULT.CFG
......................

# Your email address
$admin_email = 'seicars@gmail.com';


Your help JP will be greatly appreciated

Everton
Quote Reply
Re: [jamaicasearch41] Forward Record Mod Help In reply to
In sub html_forward_email_form, delete

<tr><td align=right><$font>Recipient's email:</font></td>
<td><input type=text name="to_email" value="$in{'to_email'}" size=40></td></tr>


In sub forward_email, delete

unless ($in{'to_email'}) { $message = "You must fill in the recipient's email address<BR>"; }

and change

print MAIL "To: $in{'to_email'}\n";

to

print MAIL "To: $admin_email\n";

You don't need to worry about having a field with the $admin_email variable defined in a field, as long as you have the variable defined elsewhere.


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [JPDeni] Forward Record Mod Help In reply to
Hi, JPdeni,

Thank again it worked...many thanks

Could you look at the delet problem i am having:..I posted the poblem under the same name

"Jamaicasearc41"
TOPIC: "cant delete a reacord"

Thanks in advance

Everton
Quote Reply
Re: [jamaicasearch41] Forward Record Mod Help In reply to
Hi JPdeni.

I ran into some problem with the "Forward Record Mod" the pobleb can be best eplained by this link below....


1. shows a record of a car

2. There are two Admin view only fields which are hidden from default viewers. "SUPPLIER" & "Fob_Buying". hidden because we dont want visitors to see where the car was bought and the price it was bought for

If you click on the button at the bottom "Enquire about this vehicle" you will notice that these 2 hidden fields in the "VEHICLE" field of the form are now showing to the Visitors (see them at the bottom of the list). This example dont have the actual price and suppliers name now...and that is because I removed the information when i discovered that the information was showing to defaul visitors.

3. I would like to hid these to hidden fields...and possible any other field I choose to hide in the "email forward Form

http://www.seicars.com/...forward_email_form=1

Thanks

I advance JPdeni
Quote Reply
Re: [jamaicasearch41] Forward Record Mod Help In reply to
In sub html_forward_email_form change

Code:
unless ($in{'email_message'}) {
foreach $col (@db_cols) {
$in{'email_message'} .= "$col: $rec{$col}\n";
}
}

to

Code:
unless ($in{'email_message'}) {
foreach $col (@db_cols) {
if ($db_form_len{$col} > -1) {
$in{'email_message'} .= "$col: $rec{$col}\n";
}
}
}



This assumes that you have set the form length to your hidden fields to -1 and the form length of your admin fields to -2.

I haven't tested it, but it should work. :-)


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.

Last edited by:

JPDeni: Apr 5, 2005, 3:10 PM
Quote Reply
Re: [JPDeni] Forward Record Mod Help In reply to
Hi JPDeni,

Could you please expand on your below statement?.....I am a novice

"This assumes that you have set the form length to your hidden fields to -1 and the form length of your admin fields to -2. "


My default.cfg:

Special => [42, 'alpha', 0, 3, 0, '', 'Yes'],
Supplier => [43, 'alpha', 20, 50, 0, '', ''],
Fob_Buying => [44, 'alpha', 20, 50, 0, '', '']

My Html.pl

if ($per_admin) {
print qq|<TR><TD ALIGN="Right" VALIGN="TOP" width="169"><$font_color>Supplier: </FONT></TD>
<TD width="430">&nbsp;<$font>$rec{'Supplier'}</Font></TD></TR>|;
}
if ($per_admin) {
print qq|<TR><TD ALIGN="Right" VALIGN="TOP" width="169"><$font_color>FOB Buying: </FONT></TD>
<TD width="430">&nbsp;<$font>$rec{'Fob_Buying'}</Font></TD></TR>|;
}
print qq|<TR><TD ALIGN="Right" VALIGN="TOP" width=169><$font_color>Enquiry Email:</TD>
<TD width="430" align="center"><a href="$db_script_link_url&$db_key=$rec{$db_key}&forward_email_form=1"><img src="/images/enquirebutton.gif" border="0"></a></TD></TR>
</TABLE>
|;
# <-- End of record display -->
}


Thanks
Quote Reply
Re: [jamaicasearch41] Forward Record Mod Help In reply to
I guess you don't have your admin-only and hidden fields set up that way. :-) What I wrote is from the readme.txt file that came with the DBMan zip file:

form-length= the length the form field should be. Set to 0 for select, checkbox or radio buttons, and set to '40x3' to make a 40 col by 3 row textarea box. Set to -1 for hidden fields. Set -2 for admin only fields.

It's likely that, if you used the Configurator, it didn't set them that way. It's been so long since I looked at the code, I don't think I'd be able to figure out what it does any more. :-)

It doesn't look like you have any way, other than how you print out the fields in the html.pl file, to determine which fields are admin and which are hidden. There's another way to do this, but it's a little more involved.

You'll need to add a specific line for each field you want to include. Something like the following

Code:
unless ($in{'email_message'}) {
$in{'email_message'} .= "ID: $rec{ID}\n";
$in{'email_message'} .= "Type: $rec{Type}\n";
$in{'email_message'} .= "Make: $rec{Make}\n";
$in{'email_message'} .= "Model: $rec{Model}\n";
}


You'll need to continue in that manner until you include all the fields you want to include. You can get fancy, if you want, and not print out blank fields or only print certain fields if you're an admin, but do this first. It may take a while. :-)


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [JPDeni] Forward Record Mod Help In reply to
*i wrote below to you and it came back that you replied to it but when i checked the forum i dont see a reply if you did reply could you resend it please.

Hi JPDeni,

Could you please expand on your below statement?.....I am a novice

"This assumes that you have set the form length to your hidden fields to -1 and the form length of your admin fields to -2. "


My default.cfg:

Special => [42, 'alpha', 0, 3, 0, '', 'Yes'],
Supplier => [43, 'alpha', 20, 50, 0, '', ''],
Fob_Buying => [44, 'alpha', 20, 50, 0, '', '']

My Html.pl

if ($per_admin) {
print qq|<TR><TD ALIGN="Right" VALIGN="TOP" width="169"><$font_color>Supplier: </FONT></TD>
<TD width="430">&nbsp;<$font>$rec{'Supplier'}</Font></TD></TR>|;
}
if ($per_admin) {
print qq|<TR><TD ALIGN="Right" VALIGN="TOP" width="169"><$font_color>FOB Buying: </FONT></TD>
<TD width="430">&nbsp;<$font>$rec{'Fob_Buying'}</Font></TD></TR>|;
}
print qq|<TR><TD ALIGN="Right" VALIGN="TOP" width=169><$font_color>Enquiry Email:</TD>
<TD width="430" align="center"><a href="$db_script_link_url&$db_key=$rec{$db_key}&forward_email_form=1"><img src="/images/enquirebutton.gif" border="0"></a></TD></TR>
</TABLE>
|;
# <-- End of record display -->
}


Thanks
Quote Reply
Re: [JPDeni] Forward Record Mod Help In reply to
Hi JP,

I am a bit slow in the head, i re-read what you said and did it and now it works

Thanks very much
Quote Reply
Re: [JPDeni] Forward Record Mod Help In reply to
Hi JpDeni,

It worked great. I am inerest in in your sujestion of hiding blank field in the form...how could I do this?

the listing really have too many black listings...

http://www.seicars.com/...forward_email_form=1


Everton
Quote Reply
Re: [jamaicasearch41] Forward Record Mod Help In reply to
I'm not sure which version you're using. If you're using the version that includes

Code:

if ($db_form_len{$col} > -1) {
$in{'email_message'} .= "$col: $rec{$col}\n";
}


You'll just add a couple of lines:

Code:

if ($db_form_len{$col} > -1) {
if ($rec{$col}) {
$in{'email_message'} .= "$col: $rec{$col}\n";
}
}


If you're using the version where you list all of the fields you want to include, you'll have to go through each one and add some lines. So that

Code:

unless ($in{'email_message'}) {
$in{'email_message'} .= "ID: $rec{ID}\n";
$in{'email_message'} .= "Type: $rec{Type}\n";
$in{'email_message'} .= "Make: $rec{Make}\n";
$in{'email_message'} .= "Model: $rec{Model}\n";
}


becomes

Code:

unless ($in{'email_message'}) {
if ($rec{ID}) {
$in{'email_message'} .= "ID: $rec{ID}\n";
}
if ($rec{Type}) {
$in{'email_message'} .= "Type: $rec{Type}\n";
}
if ($rec{Make}) {
$in{'email_message'} .= "Make: $rec{Make}\n";
}
if ($rec{Model}) {
$in{'email_message'} .= "Model: $rec{Model}\n";
}
}


In practical use, you wouldn't have to add those lines for every field. It would be just the ones that could possibly be empty.


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [JPDeni] Forward Record Mod Help In reply to
Hi JpDeni,

the script crash when i put the new code u gave me

**DBMan encountered an internal error. Please enable debugging to view**


Old code gave earlier to remove admin hidden fields:

unless ($in{'email_message'}) {
foreach $col (@db_cols) {
if ($db_form_len{$col} > -1) {
$in{'email_message'} .= "$col: $rec{$col}\n";
}
}
}


New code you gave me to hide BLANK fields in form:

unless ($in{'email_message'}) {
foreach $col (@db_cols) {
if ($db_form_len{$col} > -1) {
if ($rec{$col}) { $in{'email_message'} .= "$col: $rec{$col}\n";
}
}
}
Quote Reply
Re: [jamaicasearch41] Forward Record Mod Help In reply to
I'm not sure if I missed it or you did, but you're missing a } at the end of the routine. Give this a try:

Code:

unless ($in{'email_message'}) {
foreach $col (@db_cols) {
if ($db_form_len{$col} > -1) {
if ($rec{$col}) {
$in{'email_message'} .= "$col: $rec{$col}\n";
}
}
}
}


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [JPDeni] Forward Record Mod Help In reply to
Hi Jpdeni,

I would have responded earlier..but my internet went down for a few hours..

Thanks very much...for all your assistance I absolutely appreciate your help.

Your are a blessing

Thank again
Everton