Jumpstart your web development career using popular technologies including PHP and MySQL, Ajax, RSS, PayPal™, the Facebook Platform®, Amazon Web Services™, the Google Maps API™, the Google Analytics™ web analytics service, the Google AdSense™ and Google AdWords™ advertising services, and more! Easy PHP Websites with the Zend Framework W. Jason Gilmore Bestselling author of Beginning PHP and MySQL, Third Edition WJ Gilmore, LLC www.easyphpwebsites.com Download at Boykma.Com Easy PHP Websites with the Zend Framework W. Jason Gilmore Download at Boykma.Com Easy PHP Websites with the Zend Framework Copyright © 2009 W. Jason Gilmore Published by W.J. Gilmore, LLC 1373 Grandview Avenue, Suite 214 Columbus, Ohio 43212 All rights reserved. No part of this publication may be reproduced or transmitted in any form or by any means, electronic, mechanical, photocopying, scanning, recording or otherwise, except as permit- ted under the 1976 United States Copyright Act, without the prior written permission of the copyright owner and the publisher. Trademarks: Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to no ben- et of the trademark owner, with no intention of infringement of the trademark. Zend is a trademark of Zend Technologies Ltd. Amazon Web Services™ is a trademark of Amazon.com, Inc. Facebook® is a registered trademark of Facebook Inc. PayPal® is a registered trademark of PayPal, Inc. Google Maps API™, GoogleAdSense™, and Google AdWords™ are trademarks of Google Inc. All other trademarks are the property of their respective owners. W.J. Gilmore, LLC is not associated with any product or vendor mentioned in this book. Limit of Liability: The information in this book is distributed on an "as is" basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor W.J. Gilmore, LLC shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. Source Code: The source code for this book is available at http://www.easyphpwebsites.com/. Download at Boykma.Com Dedicated to my family Download at Boykma.Com Download at Boykma.Com Table of Contents CHAPTER 1. Conguring Your Development Environment 1 CHAPTER 2. Introducing PHP 23 CHAPTER 3. Interacting With Your Users 51 CHAPTER 4. Introducing MySQL 75 CHAPTER 5. Introducing the Zend Framework 105 CHAPTER 6. Talking to the Database with Zend_Db 137 CHAPTER 7. Processing Forms and Sending Email 161 CHAPTER 8. Managing Your User Community 183 CHAPTER 9. Integrating Google Maps 211 CHAPTER 10. Introducing the Amazon Associates Web Service 231 CHAPTER 11. Enhancing the User Interface with Ajax 245 CHAPTER 12. Extend Your Website with RSS and Facebook 263 CHAPTER 13. Monitor Trafc and Manage Ads with Google 287 CHAPTER 14. Accepting Online Payments with PayPal 305 CHAPTER 15. Introducing Zend_Tool 315 Download at Boykma.Com Expanded Table of Contents CHAPTER 1. Conguring Your Development Environment 1 Step #1. Installing Apache, MySQL, and PHP on Windows 2 Step #2. Testing Your Installation 13 Step #3: Choosing a Code Editor 14 Step #4. Exploring Other Useful Software 17 Step #5. Choosing a Web Hosting Provider 19 CHAPTER 2. Introducing PHP 23 Step #1. Creating Your First PHP-Enabled Web Page 23 Step #2. Publishing Spreadsheet Data to the Web 38 Displaying Data in a Table 41 Step #3. Managing Your Site Design Using Templates 47 CHAPTER 3. Interacting With Your Users 51 Step #1. Creating a Contact Form 52 Step #2. Validating User Input 56 Step #3. Repopulating Form Data 65 Step #4. Sending Form Data via E-mail 67 Step #5. More on Securing User Input 72 CHAPTER 4. Introducing MySQL 75 Step #1. What Is a Relational Database? 76 Step #2. Introducing MySQL 77 Step #3. Introducing phpMyAdmin 83 Step #4. Moving Your Data to MySQL 86 Step #5. Connecting Your Website to MySQL 88 Step #6. Restricting Access 103 CHAPTER 5. Introducing the Zend Framework 105 Step #1. What Is a Web Framework? 106 Step #2. Introducing the Zend Framework 112 Step #3. Installing the Zend Framework 115 Step #4. Testing Your Installation 121 Step #6. Creating the Website Layout 125 Download at Boykma.Com Step #7. Creating a Conguration File 130 Step #8. The init() Method 133 Step #9. Creating Action Helpers 133 CHAPTER 6. Talking to the Database with Zend_Db 137 Step #1. Introducing Object-relational Mapping 138 Step #2. Introducing Zend_Db 139 Step #3. Creating Your First Model 140 Step #4. Querying Your Models 141 Step #5. Creating a Row Model 145 Step #6. Inserting, Updating, and Deleting Data 146 Step #7. Modeling Table Relationships 148 Step #8. JOINing Your Data 151 Step #9. Paginating Results with Zend_Paginator 155 Step #10. Creating and Managing Views 157 CHAPTER 7. Processing Forms and Sending Email 161 Step #1. Zend Framework Forms Fundamentals 162 Step #2. Creating the GameNomad Contact Form 163 Step #3. Validating Form Data 166 Step #5. Filtering Form Data 177 Step #6. Preventing Spamming Using CAPTCHAs 178 CHAPTER 8. Managing Your User Community 183 Step #1. Creating the Users Table and Model 184 Step #2. Registering Users 188 Step #4. Displaying User Proles 203 CHAPTER 9. Integrating Google Maps 211 Step #1. Introducing the Google Maps API 212 Step #2. Adding Mapping Services to Your Website 223 CHAPTER 10. Introducing the Amazon Associates Web Service 231 Step #1. Introducing the Amazon Associates Web Service 232 Step #2. Introducing the Zend_Service_Amazon Component 234 Download at Boykma.Com Step #3. Searching for Products 239 Step #4. Customer Reviews 241 CHAPTER 11. Enhancing the User Interface with Ajax 245 Step #1. Introducing JavaScript 246 Step #2. Introducing Ajax 261 CHAPTER 12. Extend Your Website with RSS and Facebook 263 Step #1. Building and Publishing RSS Feeds 264 Step #2. Introducing the Facebook Platform 269 Step #3. Building Your First Facebook Application 274 Step #4. Introducing the Facebook PHP Client Library 276 Step #5. Creating a Facebook Platform Controller 277 Step #6. Creating a Facebook Prole Tab 280 Step #7. Sending a Facebook User Notication 282 Step #8. Adding Facebook Status Updates 283 Step #9. Deploying Your Facebook Application 285 CHAPTER 13. Monitor Trafc and Manage Ads with Google 287 Step #1: Monitoring Trafc with Google Analytics 287 Step #2. Advertising with Google AdWords 294 Step #3: Earning Money with Google AdSense 301 CHAPTER 14. Accepting Online Payments with PayPal 305 Step #1. Integrating PayPal Website Payments Standard 305 Step #2. Exploring Third-Party E-Commerce Solutions 309 CHAPTER 15. Introducing Zend_Tool 315 Step #1. Conguring Zend_Tool 315 Step #2. Creating and Managing Projects with Zend_Tool 316 Download at Boykma.Com [...]... remains the most voluminous book written on the topic in the country, if not the world If nothing else, it can hold a door open in even the most wicked Download at Boykma.Com of windstorms When I set out to write Easy PHP Websites with the Zend Framework, my strategy was decidedly different Rather than attempt to provide readers with a survey of every possible feature available to PHP, the Zend Framework, ... quite a bit of the code used to power the GameNomad website within the source code download Book Contents Easy PHP Websites with the Zend Framework is broken into fourteen chapters, and supplemented with several videos available to readers via the website http://www.easyphpwebsites.com/ Chapter 1 Configuring Your Development Environment In this introductory chapter you'll learn how to create the ultimate... Chapter 15 Introducing Zend_ Tool In the final chapter of the book, you’ll learn about the new Zend_ Tool component, a command-line utility which will make creating new Zend Framework- driven applications a breeze Download at Boykma.Com Downloading the Source Code The source code for this book is available via the website http://www.easyphpwebsites.com/ Contact the Author Over the past decade I've responded... Talking to the Database with Zend_ Db Chapter 4 showed you how to write queries which PHP which made it possible to interact with a MySQL database Although unquestionably useful, if you're like me there was something oddly unnatural about mixing PHP and SQL code together within a single script In this chapter I'll show you how to have your cake and eat it too by using the Zend_ Db component to interact with. .. easy to read up on a history of the Napoleonic campaigns as it is to create your own website on the topic And with the proliferation of powerful programming languages and frameworks such as PHP and the Zend Framework, and the ability to plug into enormous databases via services such as Amazon Associates and Google Maps API, your ambition is limited only by your creativity and understanding of how these... and MySQL database so popular? Why are they so commonly used together to build websites both large and small? This video introduces you to PHP and MySQL, focusing on the features which have turned open source projects with modest beginnings into two of the world's game-changing technologies Watch the video at http://www.easyphpwebsites.com/zfw/videos/ Chapter Steps The goals of this chapter are accomplished... without this additional installation and configuration knowledge Installing Apache, PHP, and MySQL: The Easy Way Over the years, I've received perhaps hundreds, if not thousands of reader emails The overwhelming majority of these readers wrote with support questions specific to the problems they were encountering while installing Apache, PHP, or MySQL, or getting all three to properly communicate with. .. will inform you of the successful application Click Finish to exit the configuration wizard Congratulations, MySQL is now installed! Installing PHP In the final step of the AMP installation process, we'll install PHP Like Apache and MySQL, an installer is available, making the process rather simple To begin, navigate to http://www .php. net/ downloads .php and click on the link titled PHP X.X.X installer,... placeholder for the latest stable version number From here you'll be presented with a list of servers from which you can download the installer Choose the location closest to you to begin the download process Once downloaded, double-click the installer to begin the installation process You'll be greeted with a screen welcoming you to the PHP Setup Wizard Click Next to move to the next screen The next screen... Additionally, Zend' s oversight of the Zend Framework is resulting in ever-improving synchronicity between Zend Studio and the Framework, meaning your organization is likely to reap significant rewards from adopting Zend Studio should you plan on depending heavily on Zend Framework Download at Boykma.Com 16 CHAPTER 1 • CONFIGURING YOUR DEVELOPMENT ENVIRONMENT At $399, Zend Studio isn't cheap, but it does come with . more! Easy PHP Websites with the Zend Framework W. Jason Gilmore Bestselling author of Beginning PHP and MySQL, Third Edition WJ Gilmore, LLC www.easyphpwebsites.com Download at Boykma.Com Easy PHP. LLC www.easyphpwebsites.com Download at Boykma.Com Easy PHP Websites with the Zend Framework W. Jason Gilmore Download at Boykma.Com Easy PHP Websites with the Zend Framework Copyright © 2009 W. Jason Gilmore Published. Websites with the Zend Framework, my strategy was decidedly different. Rather than attempt to provide readers with a survey of every possible feature available to PHP, the Zend Framework, and the