Page 541 - Beginning PHP 5.3
P. 541

Chapter 16: PHP and the Outside World
                                 echo “<p>Thanks for your message! Someone will be in touch shortly.</p>”;
                               }
                               else
                               {
                                 echo ‘<p>Sorry, your message could not be sent.</p>’;
                                 echo ‘<p>Please <a href=”javascript:history.go(-1)”>go back</a> to the
                             form, check the fields and try again.</p>’;
                               }
                             }

                             ?>
                               </body>
                             </html>

                         Next, change the site owner details in the script to your own name and email address:

                             define( “OWNER_FIRST_NAME”, “Michael” );
                             define( “OWNER_LAST_NAME”, “Brown” );
                             define( “OWNER_EMAIL_ADDRESS”, “michael@example.com” );

                         The script uses the HTML_QuickForm and HTML_QuickForm_Renderer_Tableless PEAR packages
                         to display and handle the contact form, so if you haven’t already done so, you’ll need to install these
                         two packages before you run the script. You can find instructions for this in Chapter 15.

                         Now run the script by visiting its URL in your Web browser. You should see a form like the one shown
                         in Figure 16-4. Enter your details into the form, along with a message subject and the message itself,
                         and then click the Send Message button to send the email. If all goes well you’ll see an
                         acknowledgement page, and the email should arrive in your inbox in a few minutes’ time.
































                               Figure 16-4
                                                                                                         503





                                                                                                      9/21/09   9:15:41 AM
          c16.indd   503
          c16.indd   503                                                                              9/21/09   9:15:41 AM
   536   537   538   539   540   541   542   543   544   545   546