Gossamer Forum
Home : Products : DBMan : Customization :

email upon deletion of record

Quote Reply
email upon deletion of record
Good Morning Carol...having a bit of a problem inserting a mail routine script into the sub delete_records routine. I want a "Confirmation of record Deletion" to be send for single or multiple deletions. Where to insert mail script and how to capture $rec{'Email'} from each form... your input is appreciated..thanks Rob
Quote Reply
Re: email upon deletion of record In reply to
This is a toughie.

It's going to require more time than I have right now. I'll get back to you.


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






Quote Reply
Re: email upon deletion of record In reply to
If you haven't already done so, add the following to your .cfg file:

Code:
# Full path to sendmail on your system
$mailprog = "|/usr/lib/sendmail -t -oeq";
# Your email address
$admin_email = 'you@yourserver.com';
# This is the field position in the database used for storing
# the email address of the one who owns the record. Set to -1 if not used.
$auth_email_field = 4;

In db.cgi, sub delete_records, change

Code:
$delete_list{$data[$db_key_pos]} ? # if this id is one we want to delete
($delete_list{$data[$db_key_pos]} = 0) : # then mark it deleted and don't print it to the new database.
($output .= $line . "\n"); # otherwise print it.

to

Code:
if ($delete_list{$data[$db_key_pos]}) {
$delete_list{$data[$db_key_pos]} = 0; # then mark it deleted and don't print it to the new database.
open (MAIL, "$mailprog") or &cgierr("Can't start mail program");
print MAIL "To: $data[$auth_email_field]\n";
print MAIL "From: $admin_email\n";
print MAIL "Subject: $html_title Confirmation of Deleted Record\n\n";
print MAIL "-" x 75 . "\n\n";
print MAIL "Your record at $html_title, which had the following information:\n";
for ($i=0;$i<=$#db_cols ;++$i) {
print MAIL "$db_cols[$i]: $data[$i]\n";
}
print MAIL "\nhas been deleted from the database.\n\n";
close MAIL;
}
else {
$output .= $line . "\n"; # otherwise print it.
}

This will send out individual email messages for each record that is deleted. I don't know how to combine multiple records for the same user in one email message.



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






Quote Reply
Re: email upon deletion of record In reply to
Hi Carol....works like a charm...thank you very much. I installed that slick little count script...works very nicely..I trying to incorporate a delete script to remove the
$rec{$db_key} when the record is deleted...thanks again I appreciate all you help....Rob
Quote Reply
Re: email upon deletion of record In reply to
Which counter mod did you install? The one with the Top Ten has a variable called "$counter_dir" which makes it so you only have to enter the directory path once.

If you don't have it in your .cfg file, add

$counter_dir = $db_script_path . "/temp";

Then, in sub delete_records, after

close MAIL;

add

Code:
unlink "$counter_dir/$data[$db_key_pos]";

It won't matter if there isn't a file there. But if there is, it will delete the file.


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






Quote Reply
Re: [JPDeni] email upon deletion of record In reply to
I have added this rountine to my cgi. I cannot for the life of me figure out what I am doing wrong.

I copied it exactly. & the only thing I did change was the "To" area. My auth admin is not used it is as -1. So, I just put in the email address it is to always go to. But, no matter what I get an internal error each time.

Can you see anything I am doing wrong? :(

CODE:

if ($delete_list{$data[$db_key_pos]}) {
$delete_list{$data[$db_key_pos]} = 0; # then mark it deleted and don't print it to the new database.
open (MAIL, "$mailprog") or &cgierr("Can't start mail program");
print MAIL "To: raeana\@newoutriders.com\n";
print MAIL "From: $admin_email\n";
print MAIL "Subject: $html_title Confirmation of Deleted Record\n\n";
print MAIL "-" x 75 . "\n\n";
print MAIL "Your record at $html_title, which had the following information:\n";
for ($i=0;$i<=$#db_cols ;++$i) {
print MAIL "$db_cols[$i]: $data[$i]\n"; }
print MAIL "\nhas been deleted from the database.\n\n";
close MAIL;
}
else {
$output .= $line . "\n"; # otherwise print it.
}

Diana Rae
Quote Reply
Re: [dianarae] email upon deletion of record In reply to
You need to check your error log. It contains details of all errors.