Jump to content

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.

 

Link to comment
https://forums.phpfreaks.com/topic/2786-update-database-and-send-an-e-mail/
Share on other sites

  • 1 month later...

[!--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 = '[email protected]';
  $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!

Archived

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

×
×
  • Create New...

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.