Gossamer Forum
Home : Products : DBMan : Customization :

How to Mail the modified record?

Quote Reply
How to Mail the modified record?
Is it possible to send a record modified by a user using Mail rather than updating it directly to the database file.

Thanks to anyone who replies to this.

Quote Reply
Re: How to Mail the modified record? In reply to
I suppose it would be possible. You would have to completely rewrite the modify_record subroutine in db.cgi.


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





Quote Reply
Re: How to Mail the modified record? In reply to
Can anyone help me write the modified sub routine for sending it using Mail

Thanx JPDeni, for your prompt reply
Quote Reply
Re: How to Mail the modified record? In reply to
I would need more of an explanation of what you want to do and why.


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





Quote Reply
Re: How to Mail the modified record? In reply to
I already have a member database file extracted from an Access 97 which has address in it, I have set the database so that anyone can view and modify it, so the only way to prevent misuse of this permisssion is to email the record to me if anyone wants to chnage his/her address and then I can change it in the file and also in access database.

I did write some code for it, but the variables are not been passed correctly, here is what I get.
Last name :60001 60001Lname)
First Name :60001 60001Fname)
Address1 :60001 60001Address1)
Address2 :60001 60001Address2)
Address3 :60001 60001Address3)
City :60001 60001City)
State :60001 60001State)
etc ...

And the modification is done in db.cgi
Quote Reply
Re: How to Mail the modified record? In reply to
So you want to be able to make the change yourself, after the user enters the data, right?

This is completely untested, but ought to work.

Code:
sub modify_record {
# --------------------------------------------------------
my ($status, $line, @lines, @data, $output, $found, $restricted);

$status = &validate_record; # Check to make sure the modifications are ok!

if ($per_admin) {
# [keep all the rest of the subroutine as it is]
# end with the following lines that are already in the subroutine
else {
&html_modify_failure($status); # Validation Error
}
}

# mail modifications, if entered by a user
else {
if ($status eq "ok") {
$mailprog = $mailprog = "|/usr/lib/sendmail -t"; # adjust to the mail program on your server
$admin_email = you\@server.com # use your own email address
open (MAIL, "$mailprog") or &cgierr( "Can't start mail program");
print MAIL "To: $admin_email\n";
print MAIL "From: $admin_email\n";
print MAIL "Subject: Modified Record\n\n";
foreach $column (@db_cols) {
print MAIL "$column: $in{$column}\n";
}
close MAIL;
# send the user to a page telling them that the modification has been sent
}
else {
&html_modify_failure($status); # Validation Error
}
}
}

You'll also need to create a page that tells the user the modification has been sent. A new subroutine in html.pl should do it -- maybe similar to html_delete_success.

I'm not sure why you got the results you did. I'd have to see the code you used.

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





Quote Reply
Re: How to Mail the modified record? In reply to
Thank you JPDeni.
It works at last