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
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 = '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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.