Jump to content


Photo

Email upon new database entry?


  • Please log in to reply
3 replies to this topic

#1 markspec87

markspec87
  • Members
  • PipPipPip
  • Advanced Member
  • 63 posts

Posted 05 September 2006 - 06:01 PM

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)

#2 Stevis2002

Stevis2002
  • Members
  • PipPipPip
  • Advanced Member
  • 98 posts

Posted 05 September 2006 - 06:06 PM

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?

#3 roopurt18

roopurt18
  • Staff Alumni
  • Advanced Member
  • 3,749 posts
  • LocationCalifornia, southern

Posted 05 September 2006 - 07:28 PM

if(mysql_insert($sql) == 1){
  SendMail();
}
PHP Forms : Part I | Part II

JavaScript: Singleton

http://www.rbredlau.com

#4 Stevis2002

Stevis2002
  • Members
  • PipPipPip
  • Advanced Member
  • 98 posts

Posted 05 September 2006 - 07:33 PM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users