Jump to content

Archived

This topic is now archived and is closed to further replies.

athosflorides

Update database and send an e-mail

Recommended Posts

Hello there!

I've been trying the last few dates to create a function that not only inserts a record into my database but also notifies the administrators with an e-mail that specific data have been inserted.

This a request form for support. The user submits the form and the new entry goes to my database. In order to avoid checking the database all the time for new requests, I want that values inserted to be e-mailed to a list of recipients.

Can someone provide me with some information please?

Upto now i have it working fine BUT without the e-mail function.

 

Thank you.

 

Share this post


Link to post
Share on other sites

Well after you insert the record use the mail() function. Browse the php manual or goto the Macromedia site and get the free php mail .mxp available.

Share this post


Link to post
Share on other sites

[!--quoteo(post=314026:date=Nov 2 2005, 11:40 AM:name=athosflorides)--][div class=\'quotetop\']QUOTE(athosflorides @ Nov 2 2005, 11:40 AM) 314026[/snapback][/div][div class=\'quotemain\'][!--quotec--]

Hello there!

I've been trying the last few dates to create a function that not only inserts a record into my database but also notifies the administrators with an e-mail that specific data have been inserted.

This a request form for support. The user submits the form and the new entry goes to my database. In order to avoid checking the database all the time for new requests, I want that values inserted to be e-mailed to a list of recipients.

Can someone provide me with some information please?

Upto now i have it working fine BUT without the e-mail function.

 

Thank you.

 

the idea is to run a check to make sure that you are successfully inserting the record into the DB. if it is a success, then emal. so, you'd want to run something like this:

 

<?php
$sql = "INSERT INTO tablename VALUES ('', 'whatever')"; // this is your query
if (mysql_query($sql)) // returns true if it's successful
{
  $to = 'you@yourdomain.com';
  $sub = "New DB entry";
  $msg = "New entry has been entered, values are: "; // any message you want to send
  mail($to, $sub, $msg);
}
?>

 

that's really all ther is to it (with some modifications to fit your code, obviously).

 

good luck!

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.