markspec87 Posted September 5, 2006 Share Posted September 5, 2006 I have a page where users can submit thier own news / articles.When they complete this form is there any code ican use to email me that someone has added something (at the same time as it adds it to the database) Link to comment https://forums.phpfreaks.com/topic/19793-email-upon-new-database-entry/ Share on other sites More sharing options...
Stevis2002 Posted September 5, 2006 Share Posted September 5, 2006 Yes, i should think that you could do an 'if' statement which checks to see if the id, (which hopefully is auto incremented when a new record is inserted), has gone up one, and then in the statement put the mail function.Something like that? Link to comment https://forums.phpfreaks.com/topic/19793-email-upon-new-database-entry/#findComment-86549 Share on other sites More sharing options...
roopurt18 Posted September 5, 2006 Share Posted September 5, 2006 if(mysql_insert($sql) == 1){ SendMail();} Link to comment https://forums.phpfreaks.com/topic/19793-email-upon-new-database-entry/#findComment-86610 Share on other sites More sharing options...
Stevis2002 Posted September 5, 2006 Share Posted September 5, 2006 An easier way might be to add the code into a function.EG, the function which sends all the info to the db, should post an error if there is a problem, which makes your if - else statements.So under the actual process for posting the info into the db, you could add the process for mailing a email to yourself, and if anythink fails, then it will give the user the standard db error Link to comment https://forums.phpfreaks.com/topic/19793-email-upon-new-database-entry/#findComment-86614 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.