Jump to content


Photo

Update database and send an e-mail


  • Please log in to reply
2 replies to this topic

#1 athosflorides

athosflorides
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 02 November 2005 - 04:40 PM

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.


#2 morpheus.100

morpheus.100
  • Members
  • PipPipPip
  • Advanced Member
  • 145 posts

Posted 07 December 2005 - 10:44 AM

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.

#3 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 07 December 2005 - 01:47 PM

[!--quoteo(post=314026:date=Nov 2 2005, 11:40 AM:name=athosflorides)--][div class=\'quotetop\']QUOTE(athosflorides @ Nov 2 2005, 11:40 AM) View Post[/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.
[/quote]

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!
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users