Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

E-mail after record inserted

New Here ,
Dec 28, 2006 Dec 28, 2006
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!
TOPICS
Server side applications
388
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 28, 2006 Dec 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/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 05, 2007 Jan 05, 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!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 05, 2007 Jan 05, 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/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 07, 2007 Mar 07, 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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 07, 2007 Mar 07, 2007
LATEST
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/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines