PDA

View Full Version : Php Question Re: Auto Email When Addition to DB



Robert
April 1st, 2004, 13:21
Howdy,

I'm writing a small mailing list script for my friend that basically takes a few fields, stores them in a database and allows him to go into phpmyadmin and export the database in CVS (later down the road I'll write a script that will simplify this - if anyone knows how, please post it. thanks).

He wants the script to email him everytime someone adds their information to the database.

So I'm looking for a piece of code that would send him an email with what was added.

I've looked around and not sure where to start on this part (kinda trickey).

I'm assuming I'd add another query to email the same information.. not sure how I'd go about that (Still a beginner).

Any help is appreciated.

Thanks

kabatak
April 1st, 2004, 23:00
just add a mail() function some where in code:



<?
$to = 'admin@website.com';
$subject = 'Somebody was added in your mailing list';
$message = 'A new email '.$_POST['email'].' was added in your mailing list';

mail($to, $subject, $message);
?>

Robert
April 2nd, 2004, 10:13
Thanks. That's exactly what I thought of doing after I posted here. lol.