Skip to main content
Known Participant
December 28, 2006
Question

E-mail after record inserted

  • December 28, 2006
  • 5 replies
  • 392 views
I have an order request form that when submitted, not only do I want it to be added to the database but also send me an e-mail that an order was submitted. Any ideas on how to do this? Using DW8, PHP5 and MySQL 5.

I don't need it to be fancy, telling me what the order was for or who it was from. I just want a generic message saying, "A new order has been submitted."

Thanks!
This topic is closed to new replies. Start a new post to keep the conversation going.

5 replies

Inspiring
March 7, 2007
Eiolon wrote:
> I've tried this:
>
> mail('person@example.com','Order submitted', 'A new order has been
> submitted. http://site.com', 'me@example.com');
>
> But it adds me@example.com to the actual message body and not the header.

mail('person@example.com','Order submitted', 'A new order has been
submitted. http://site.com', 'From: me@example.com');

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
EiolonAuthor
Known Participant
March 7, 2007
I've been using this and it works pretty well. One thing I notice is its saying its from "Nobody" and is probably using the php.ini settings for the sendmail. Since I am on a shared server I dont have access to that info and change it. Is there a way to change who it is coming from in the From field?

I've tried this:

mail('person@example.com','Order submitted', 'A new order has been
submitted. http://site.com', 'me@example.com');

But it adds me@example.com to the actual message body and not the header. Thanks for your help!

Inspiring
January 5, 2007
Eiolon wrote:
> mail('me@example.com','Order submitted', 'A new order has been
> submitted. <a href=" http://site.com">Click here to view orders</a>');
>
> It mails the actual HTML and doesn't make it a link. Thanks!

The PHP mail() function doesn't support HTML, although example 4 on the
following page shows you how it can be done:

http://www.php.net/manual/en/function.mail.php

However, most email programs turn URLs into links in plain text emails,
so it's not really necessary.

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
EiolonAuthor
Known Participant
January 5, 2007
Hi - thanks for the help. This is working nicely.

One more question, how do I get it to e-mail a link to the order page? When I put the HTML for the link such as this:

mail('me@example.com','Order submitted', 'A new order has been
submitted. <a href=" http://site.com">Click here to view orders</a>');

It mails the actual HTML and doesn't make it a link. Thanks!
Inspiring
December 28, 2006
Eiolon wrote:
> I don't need it to be fancy, telling me what the order was for or who it was
> from. I just want a generic message saying, "A new order has been submitted."

Find this line in the code above the DOCTYPE:

header(sprintf("Location: %s", $insertGoTo));

Insert a new line immediately in front of it, and add this:

mail('me@example.com','Order submitted', 'A new order has been
submitted');

Use your own email address instead of me@example.com.

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/