O'Reilly logo

Web Database Applications with PHP, and MySQL by David Lane, Hugh E. Williams

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

HTML and Email Receipts

Once an order has been processed, the winestore application confirms the shipping of the wines through both an email and an HTML receipt. The order.3 script redirects to the shipping.1 script shown in Example 12-2, which sends the user an email. In turn, the shipping.1 script redirects to the shipping.2 script shown in Example 12-3, which produces the HTML receipt. The HTML receipt can be visited again at a later time by bookmarking the URL and, as it carries out no database updates, it doesn’t suffer from the reload problem described in Chapter 6. The receipt functionality is separated into two scripts so that returning to the HTML receipt doesn’t cause an additional email receipt to be sent to the customer.

The function send_confirmation_email( ) in Example 12-2 creates the destination address, the subject, the body, and additional headers of an email message, and then sends that email message. The destination to address is created using the firstname, the surname, and the email address of the customer so that, for example, it has the following format:

Michael Smith <mike@webdatabasebook.com>

The additional email headers are static and always have the following format:

From: "Hugh and Dave's Online Wines" <help@webdatabasebook.com>                                                                               
X-Sender: <help@webdatabasebook.com>                                                                                                          
X-Mailer: PHP                                                                                                                                 
X-Priority: 1
Return-Path: <help@webdatabasebook.com>

The subject of the email is always:

$subject = "Hugh and Dave's Online Wines: Order 
            Confirmation";

The body of the message ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required