PHP And MySQL Web Development

Transcription

“I’ve never purchased a betterprogramming book This book provedto be the most informative, easiest tofollow, and had the best examples ofany other computer-related book I haveever purchased. The text is very easy tofollow!”—Nick Landman“This book by Welling & Thomsonis the only one which I have found tobe indispensable. The writing is clearand straightforward but never wastesmy time. The book is extremely welllaid out. The chapters are the rightlength and chapter titles quickly takeyou where you want to go.”—Wright Sullivan, President,A&E Engineering, Inc.,Greer South Carolina“I just wanted to tell you thatI think the book PHP and MySQLWeb Development rocks! It’s logicallystructured, just the right difficulty levelfor me (intermediate), interesting andeasy to read, and, of course, full ofvaluable information!”—CodE-E, Austria“There are several goodintroductory books on PHP, butWelling & Thomson is an excellenthandbook for those who wish to buildup complex and reliable systems. It’sobvious that the authors have a strongbackground in the development ofprofessional applications and theyteach not only the language itself, butalso how to use it with good softwareengineering practices.”—Javier Garcia, senior telecom engineer, Telefonica R&D Labs, Madrid“I picked up this book two days agoand I am half way finished. I just can’tput it down. The layout and flow isperfect. Everything is presented in sucha way so that the information is verypalatable. I am able to immediately graspall the concepts. The examples have alsobeen wonderful. I just had to take sometime out to express to you how pleasedI have been with this book.”—Jason B. Lancaster“This book has proven a trustycompanion, with an excellent crashcourse in PHP and superb coverage ofMySQL as used for Web applications.It also features several completeapplications that are great examplesof how to construct modular, scalableapplications with PHP. Whether youare a PHP newbie or a veteran in searchof a better desk-side reference, this oneis sure to please!”—WebDynamic“The true PHP/MySQL bible, PHPand MySQL Web Development by LukeWelling and Laura Thomson, made merealize that programming and databasesare now available to the commoners.Again, I know 1/10000th of what thereis to know, and already I’m enthralled.”—Tim Luoma, TnTLuoma.com“Welling and Thomson’s book isa good reference for those who wantto get to grips with practical projectsstraight off the bat. It includes webmail,shopping cart, session control, andweb-forum/weblog applications as amatter of course, and begins with asturdy look at PHP first, moving toMySQL once the basics are covered.”—twilight30 on Slashdot

“This book is absolutely excellent,to say the least . Luke Welling andLaura Thomson give the best in-depthexplanations I’ve come across on suchthings as regular expressions, classes andobjects, sessions etc. I really feel thisbook filled in a lot of gaps for me withthings I didn’t quite understand . Thisbook jumps right into the functionsand features most commonly used withPHP, and from there it continues indescribing real-world projects, MySQLintegration, and security issues froma project manager’s point of view.I found every bit of this book to be wellorganized and easy to understand.”—notepad on codewalkers.com“A top-notch reference forprogrammers using PHP and MySQL.Highly recommended.”—The Internet Writing Journal“This book rocks! I am anexperienced programmer, so I didn’tneed a lot of help with PHP syntax;after all, it’s very close to C/C . I don’tknow a thing about databases, though,so when I wanted to develop a bookreview engine (among other projects)I wanted a solid reference to usingMySQL with PHP. I have O’Reilly’smSQL and MySQL book, and it’sprobably a better pure-SQL reference,but this book has earned a place on myreference shelf Highly recommended.”applications with two of the mostpopular open-source Web developmenttechnologies . The projects are thereal jewel of the book. Not only are theprojects described and constructed ina logical, component-based manner,but the selection of projects representsan excellent cross-section of commoncomponents that are built into manyweb sites.”—Craig Cecil“The book takes an easy, step-bystep approach to introduce even theclueless programmer to the language ofPHP. On top of that, I often find myselfreferring back to it in my Web designefforts. I’m still learning new thingsabout PHP, but this book gave me asolid foundation from which to startand continues to help me to this day.”—Stephen Ward“This book is one of few that reallytouched me and made me ‘love’ it.I can’t put it in my bookshelf; I mustput it in a touchable place on myworking bench as I always like to referfrom it. Its structure is good, wordingsare simple and straight forward, andexamples are clear and step by step.Before I read it, I knew nothing of PHPand MySQL. After reading it, I have theconfidence and skill to develop anycomplicated Web application.”—Power Wong—Paul Robichaux“One of the best programmingguides I’ve ever read.”—jackofsometrades from Lahti, Finland“This is a well-written bookfor learning how to build Internet“This book is God . I highlyrecommend this book to anyonewho wants to jump in the deep endwith database driven Web applicationprogramming. I wish more computerbooks were organized this way.”—Sean C Schertell

PHP and MySQLWeb Development Fifth Edition

Developer’s LibraryESSENTIAL REFERENCES FOR PROGRAMMING PROFESSIONALSDeveloper’s Library books are designed to provide practicing programmers with unique,high-quality references and tutorials on the programming languages and technologiesthey use in their daily work.All books in the Developer’s Library are written by expert technology practitioners whoare especially skilled at organizing and presenting information in a way that’s useful forother programmers.Key titles include some of the best, most widely acclaimed books within theirtopic areas:PHP & MySQLWeb DevelopmentLuke Welling & Laura ThomsonPython Essential ReferenceDavid BeazleyMySQLPaul DuBoisNode.js, MongoDB and AngularWeb DevelopmentBrad DayleyProgramming in CStephen KochanC Primer PlusStephen PrataDeveloper’s Library books are available in print and in electronic formats at mostretail and online bookstores, as well as by subscription from Safari Books Online com/devlibrary

PHP and MySQLWeb Development Fifth EditionLuke WellingLaura ThomsonHoboken, NJ Boston Indianapolis San FranciscoNew York Toronto Montreal London Munich Paris MadridCape Town Sydney Tokyo Singapore Mexico City

PHP and MySQL Web DevelopmentCopyright 2017 by Pearson Education, Inc.All rights reserved. No part of this book shall be reproduced, stored in a retrieval system,or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise,without written permission from the publisher. No patent liability is assumed with respectto the use of the information contained herein. Although every precaution has been takenin the preparation of this book, the publisher and authors assume no responsibility forerrors or omissions. Nor is any liability assumed for damages resulting from the use of theinformation contained herein.ISBN-13: 978-0-321-83389-1ISBN-10: 0-321-83389-9Library of Congress Control Number: 2016934688Printed in the United States of AmericaFirst Printing: September 2016TrademarksAll terms mentioned in this book that are known to be trademarks or service marks havebeen appropriately capitalized. Pearson cannot attest to the accuracy of this information.Use of a term in this book should not be regarded as affecting the validity of any trademarkor service mark.Warning and DisclaimerEvery effort has been made to make this book as complete and as accurate as possible,but no warranty or fitness is implied. The information provided is on an “as is” basis. Theauthors and the publisher shall have neither liability nor responsibility to any person or entitywith respect to any loss or damages arising from the information contained in this book.Special SalesFor information about buying this title in bulk quantities, or for special sales opportunities(which may include electronic versions; custom cover designs; and content particular to yourbusiness, training goals, marketing focus, or branding interests), please contact ourcorporate sales department at corpsales@pearsoned.com or (800) 382-3419.For government sales inquiries, please contact governmentsales@pearsoned.com.For questions about sales outside the U.S., please contact intlcs@pearson.com.EditorMark TaberProject EditorLori LyonsProject ManagerDhayanidhiCopy EditorLori EbyIndexerTim WrightTechnical EditorJulie Meloni

Contents at a GlanceIntroduction 1I: Using PHP1 PHP Crash Course112 Storing and Retrieving Data3 Using Arrays53754 String Manipulation and Regular Expressions5 Reusing Code and Writing Functions6 Object-Oriented PHP1011311597 Error and Exception Handling199II: Using MySQL8 Designing Your Web Database9 Creating Your Web Database20922110 Working with Your MySQL Database24711 Accessing Your MySQL Database from the Web with PHP12 Advanced MySQL Administration13 Advanced MySQL Programming291315III: Web Application Security14 Web Application Security Risks33115 Building a Secure Web Application34116 Implementing Authentication Methods with PHP365IV: Advanced PHP Techniques17 Interacting with the File System and the Server18 Using Network and Protocol Functions19 Managing the Date and Time423403379271

viiiContents at a Glance20 Internationalization and Localization21 Generating Images43744922 Using Session Control in PHP23 Integrating JavaScript and PHP24 Other Useful Features475493519V: Building Practical PHP and MySQL Projects25 Using PHP and MySQL for Large Projects26 Debugging and Logging52954327 Building User Authentication and Personalization56128 Building a Web-Based Email Service with Laravel Part IWeb Edition29 Building a Web-Based Email Service with Laravel Part IIWeb Edition30 Social Media Integration Sharing and Authentication31 Building a Shopping CartWeb EditionVI: AppendixA Installing Apache, PHP, and MySQLIndex 615599Web Edition

Table of ContentsIntroduction1I: Using PHP1 PHP Crash Course11Before You Begin: Accessing PHP12Creating a Sample Application: Bob’s Auto PartsCreating the Order FormProcessing the Form14Embedding PHP in HTMLPHP Tags121416PHP StatementsWhitespaceComments161717Adding Dynamic ContentCalling Functions1819Using the date() FunctionAccessing Form VariablesForm Variables20String Concatenation22Variables and Literals23Understanding Identifiers23Examining Variable Types24PHP’s Data TypesType StrengthType Casting242525Variable Variables25Declaring and Using ConstantsUnderstanding Variable ScopeUsing Operators192028Arithmetic OperatorsString Operators2829Assignment Operators29Comparison Operators31Logical Operators32262712

xContentsBitwise OperatorsOther Operators3333Working Out the Form Totals36Understanding Precedence and AssociativityUsing Variable Handling Functions39Testing and Setting Variable TypesTesting Variable Status373940Reinterpreting Variables41Making Decisions with Conditionals41if Statements 41Code Blocks42else Statements 42elseif Statements 43switch Statements 44Comparing the Different ConditionalsRepeating Actions Through Iteration4546while Loops 47for and foreach Loops 49do.while Loops 50Breaking Out of a Control Structure or ScriptEmploying Alternative Control Structure SyntaxUsing declare 51Next522 Storing and Retrieving DataSaving Data for Later5353Storing and Retrieving Bob’s OrdersProcessing FilesOpening a File545555Choosing File Modes55Using fopen() to Open a File56Opening Files Through FTP or HTTP58Addressing Problems Opening Files58Writing to a File61Parameters for fwrite() 62File FormatsClosing a File62635051

ContentsReading from a File65Opening a File for Reading: fopen() 6666Knowing When to Stop: feof()Reading a Line at a Time: fgets(), fgetss(),and fgetcsv() 67Reading the Whole File: readfile(), fpassthru(),file(), and file get contents() 6869Reading a Character: fgetc()Reading an Arbitrary Length: fread() 69Using Other File Functions69Checking Whether a File Is There: file exists() 70Determining How Big a File Is: filesize() 70Deleting a File: unlink() 70Navigating Inside a File: rewind(), fseek(), and ftell() 70Locking Files 71A Better Way: Databases73Problems with Using Flat Files73How RDBMSs Solve These ProblemsFurther ReadingNext7474743 Using Arrays75What Is an Array?75Numerically Indexed Arrays76Initializing Numerically Indexed ArraysAccessing Array ContentsUsing Loops to Access the ArrayArrays with Different IndicesInitializing an ArrayUsing Loops798179Multidimensional ArraysSorting Arrays7879Accessing the Array ElementsArray Operators7677798285Using sort() 85Using asort() and ksort() to Sort ArraysSorting in Reverse8786xi

xiiContentsSorting Multidimensional Arrays87Using the array multisort() functionUser-Defined Sorts88Reverse User Sorts89Reordering Arrays8790Using shuffle() 90Reversing an Array92Loading Arrays from Files92Performing Other Array Manipulations96Navigating Within an Array: each(), current(), reset(),end(), next(), pos(), and prev() 96Applying Any Function to Each Element in an Array:array walk() 97Counting Elements in an Array: count(), sizeof(),and array count values() 98Converting Arrays to Scalar Variables: extract() 99Further ReadingNext1001004 String Manipulation and Regular Expressions101Creating a Sample Application: Smart Form MailFormatting Strings101104Trimming Strings: chop(), ltrim(), and trim() 104Formatting Strings for Output105Joining and Splitting Strings with String FunctionsUsing explode(), implode(), and join()112112Using strtok() 113Using substr() 114Comparing Strings115Performing String Ordering: strcmp(), strcasecmp(),and strnatcmp() 115Testing String Length with strlen()115Matching and Replacing Substrings with String Functions116Finding Strings in Strings: strstr(), strchr(), strrchr(),and stristr() 116Finding the Position of a Substring: strpos()and strrpos() 117Replacing Substrings: str replace()and substr replace() 118

ContentsIntroducing Regular ExpressionsThe Basics119120Delimiters120Character Classes and TypesRepetition120122Subexpressions122Counted Subexpressions123Anchoring to the Beginning or End of a StringBranching123123Matching Literal Special CharactersReviewing Meta CharactersEscape tting It All Together for the Smart Form127Finding Substrings with Regular Expressions128Replacing Substrings with Regular ExpressionsSplitting Strings with Regular ExpressionsFurther ReadingNext1291291301305 Reusing Code and Writing FunctionsThe Advantages of Reusing CodeCost131131132Reliability132Consistency132Using require() and include()132Using require() to Include Code133Using require() for Website Templates134Using auto prepend file and auto append file 139Using Functions in PHPCalling Functions140141Calling an Undefined Function142Understanding Case and Function NamesDefining Your Own Functions144Examining Basic Function StructureNaming Your FunctionUsing Parameters146145144143xiii

xivContentsUnderstanding Scope148Passing by Reference Versus Passing by ValueUsing the return Keyword152Returning Values from FunctionsImplementing Recursion150153154Implementing Anonymous Functions (or Closures)Further ReadingNext1551571576 Object-Oriented PHP159Understanding Object-Oriented ConceptsClasses and ObjectsPolymorphismInheritance160160161161Creating Classes, Attributes, and Operations in PHPStructure of a ing ClassesUsing Class Attributes163164Calling Class Operations165Controlling Access with private and publicWriting Accessor Functions166166Implementing Inheritance in PHP168Controlling Visibility Through Inheritance with privateand protected 169Overriding170Preventing Inheritance and Overriding with final 172Understanding Multiple InheritanceImplementing InterfacesUsing Traits172173174Designing Classes176Writing the Code for Your Class177Understanding Advanced Object-Oriented Functionality in PHPUsing Per-Class Constants185Implementing Static Methods185Checking Class Type and Type Hinting185185

ContentsLate Static BindingsCloning Objects186187Using Abstract Classes188Overloading Methods with call() 188Using autoload() 189Implementing Iterators and IterationGenerators190192Converting Your Classes to StringsUsing the Reflection APINamespaces194194195Using Subnamespaces197Understanding the Global NamespaceImporting and Aliasing NamespacesNext1971981987 Error and Exception HandlingException Handling ConceptsThe Exception Class201User-Defined Exceptions202199199Exceptions in Bob’s Auto Parts204Exceptions and PHP’s Other Error Handling MechanismsFurther ReadingNext208208208II: Using MySQL8 Designing Your Web DatabaseRelational Database 211211Schemas212Relationships213Designing Your Web Database213Think About the Real-World Objects You Are ModelingAvoid Storing Redundant Data214213xv

xviContentsUse Atomic Column ValuesChoose Sensible Keys216217Think About What You Want to Ask the DatabaseAvoid Designs with Many Empty AttributesSummary of Table Types218Web Database Architecture218Further ReadingNext2172172202209 Creating Your Web DatabaseUsing the MySQL MonitorLogging In to MySQL221222223Creating Databases and Users224Setting Up Users and Privileges225Introducing MySQL’s Privilege SystemPrinciple of Least Privilege225225User Setup: The CREATE USER and GRANT CommandsTypes and Levels of PrivilegesThe REVOKE Command225227230Examples Using GRANT and REVOKE 230Setting Up a User for the WebUsing the Right Database232Creating Database Tables232231Understanding What the Other Keywords MeanUnderstanding the Column Types234235Looking at the Database with SHOW and DESCRIBE 237Creating Indexes238Understanding MySQL Identifiers239Choosing Column Data Types 240Numeric Types241Date and Time TypesString TypesFurther ReadingNext24324424624610 Working with Your MySQL DatabaseWhat Is SQL?247Inserting Data into the Database248247

ContentsRetrieving Data from the Database250Retrieving Data with Specific Criteria251Retrieving Data from Multiple Tables253Retrieving Data in a Particular Order259Grouping and Aggregating Data259Choosing Which Rows to ReturnUsing Subqueries261262Updating Records in the DatabaseAltering Tables After Creation265265Deleting Records from the DatabaseDropping Tables268Dropping a Whole DatabaseFurther ReadingNext26826826926911 Accessing Your MySQL Database from the Web with PHPHow Web Database Architectures WorkQuerying a Database from the Web275Checking and Filtering Input DataSetting Up a Connection276277Choosing a Database to UseQuerying the Database278278Using Prepared StatementsRetrieving the Query Results279280Disconnecting from the Database281Putting New Information in the DatabaseUsing Other PHP-Database Interfaces282286Using a Generic Database Interface: PDOFurther ReadingNext27127228628928912 Advanced MySQL Administration291Understanding the Privilege System in DetailThe user TableThe db Table291293295The tables priv, columns priv, and procs priv TablesAccess Control: How MySQL Uses the Grant Tables298Updating Privileges: When Do Changes Take Effect?299296xvii

xviiiContentsMaking Your MySQL Database Secure299MySQL from the Operating System’s Point of ViewPasswords299300User PrivilegesWeb Issues300301Getting More Information About DatabasesGetting Information with SHOW301302Getting Information About Columns with DESCRIBE 304Understanding How Queries Work with EXPLAINOptimizing Your DatabaseDesign OptimizationPermissions309309Table OptimizationUsing Indexes310310Using Default ValuesOther Tips309310310Backing Up Your MySQL DatabaseRestoring Your MySQL DatabaseImplementing Replication311Setting Up the Master312310311Performing the Initial Data TransferSetting Up the Slave or SlavesFurther ReadingNext31331331431413 Advanced MySQL Programming 315The LOAD DATA INFILE Statement 315Storage EnginesTransactions316317Understanding Transaction DefinitionsUsing Transactions with InnoDBForeign Keys318319Stored Procedures320Basic Example320Local Variables323Cursors and Control Structures323317304

ContentsTriggers327Further ReadingNext329329III: Web Application Security14 Web Application Security Risks331Identifying the Threats We FaceAccess to Sensitive DataModification of Data331331334Loss or Destruction of DataDenial of ServiceMalicious Code InjectionCompromised ServerRepudiation334335337338338Understanding Who We’re Dealing WithAttackers and Crackers339339Unwitting Users of Infected MachinesDisgruntled EmployeesHardware ThievesOurselvesNext33934034034015 Building a Secure Web ApplicationStrategies for Dealing with SecurityStart with the Right Mindset342Balancing Security and UsabilityMonitoring Security342Our Basic Approach343Securing Your Code343Filtering User InputEscaping OutputCode Organization343348350What Goes in Your Code351File System ConsiderationsCode Stability and BugsExecuting Commands352352353341341342339xix

xxContentsSecuring Your Web Server and PHPKeep Software Up-to-Date354354Browse the php.ini file 355Web Server Configuration356Shared Hosting of Web ApplicationsDatabase Server Security356357Users and the Permissions SystemSending Data to the Server358358Connecting to the Server 359Running the Server359Protecting the Network360Firewalls360Use a DMZ360Prepare for DoS and DDoS Attacks361Computer and Operating System SecurityKeep the Operating System Up to DateRun Only What Is Necessary362Physically Secure the Server362Disaster PlanningNext36136136236416 Implementing Authentication Methods with PHPIdentifying Visitors365365Implementing Access ControlStoring Passwords366369Securing Passwords369Protecting Multiple Pages 371Using Basic Authentication372Using Basic Authentication in PHP372Using Basic Authentication with Apache’s .htaccess FilesCreating Your Own Custom AuthenticationFurther ReadingNext377377377IV: Advanced PHP Techniques17 Interacting with the File System and the ServerUploading Files379HTML for File Upload381379374

ContentsWriting the PHP to Deal with the FileSession Upload ProgressAvoiding Common Upload ProblemsUsing Directory Functions382387389390Reading from Directories390Getting Information About the Current DirectoryCreating and Deleting DirectoriesInteracting with the File SystemGetting File Information394394395395Changing File Properties397Creating, Deleting, and Moving FilesUsing Program Execution Functions398398Interacting with the Environment: getenv() and putenv()Further ReadingNext40240218 Using Network and Protocol FunctionsExamining Available ProtocolsSending and Reading Email403404Using Data from Other Websites404Using Network Lookup Functions408Backing Up or Mirroring a File412Using FTP to Back Up or Mirror a FileUploading Files420Using Other FTP FunctionsNext412420Avoiding TimeoutsFurther Reading40342042142119 Managing the Date and Time423Getting the Date and Time from PHPUnderstanding Timezones423423Using the date() Function424Dealing with Unix TimestampsUsing the getdate() Function426427Validating Dates with checkdate() 428Formatting Timestamps429Converting Between PHP and MySQL Date Formats431401xxi

xxiiContentsCalculating Dates in PHP433Calculating Dates in MySQL 434Using Microseconds435Using the Calendar FunctionsFurther ReadingNext43643643620 Internationalization and LocalizationLocalization Is More than TranslationUnderstanding Character Sets437437438Security Implications of Character Sets439Using Multibyte String Functions in PHP440Creating a Basic Localizable Page Structure440Using gettext() in an Internationalized Application444Configuring Your System to Use gettext() 444Creating Translation Files445Implementing Localized Content in PHP Using gettext() 447Further ReadingNext44844821 Generating Images449Setting Up Image Support in PHPUnderstanding Image FormatsJPEG450PNG450GIF449450451Creating Images451Creating a Canvas Image452Drawing or Printing Text on the ImageOutputting the Final GraphicCleaning Up453455455Using Automatically Generated Images in Other PagesUsing Text and Fonts to Create ImagesSetting Up the Base Canvas460Fitting the Text onto the ButtonPositioning the Text465461464Writing the Text onto the ButtonFinishing Up457464456

ContentsDrawing Figures and Graphing DataUsing Other Image FunctionsNext46547447422 Using Session Control in PHPWhat Is Session Control?475475Understanding Basic Session FunctionalityWhat Is a Cookie?476476Setting Cookies from PHP476Using Cookies with SessionsStoring the Session IDImplementing Simple SessionsStarting a Session477477478478Registering Session VariablesUsing Session Variables478479Unsetting Variables and Destroying the SessionCreating a Simple Session ExampleConfiguring Session Control482Implementing Authentication with Session ControlNext48349123 Integrating JavaScript and PHPUnderstanding AJAX493493A Brief Introduction to jQuery494Using jQuery in Web ApplicationsUsing jQuery and AJAX with PHP494504The AJAX-Enabled Chat Script/ServerThe jQuery AJAX MethodsFurther Reading504507The Chat Client/jQuery ApplicationNext47948051051751724 Other Useful Features 519Evaluating Strings: eval() 519Terminating Execution: die() and exit() 520Serializing Variables and Objects521Getting Information About the PHP EnvironmentFinding Out What Extensions Are Loaded522522xxiii

xxivContentsIdentifying the Script Owner523Finding Out When the Script Was Modified523Temporarily Altering the Runtime Environment524Highlighting Source Code525Using PHP on the Command LineNext526527V: Building Practical PHP and MySQL Projects25 Using PHP and MySQL for Large Projects529Applying Software Engineering to Web DevelopmentPlanning and Running a Web Application ProjectReusing Code531Writing Maintainable Code532Coding Standards532Breaking Up Code535Using a Standard Directory Structure536Documenting and Sharing In-House FunctionsImplementing Version Control536Choosing a Development EnvironmentDocumenting Your ProjectsPrototyping537538538Separating Logic and Content 539Optimizing Code540Using Simple OptimizationsTesting540541Further ReadingNext54254226 Debugging and LoggingProgramming ErrorsSyntax Errors543543543Runtime ErrorsLogic Errors530530544549Variable Debugging AidError Reporting Levels551553Altering the Error Reporting SettingsTriggering Your Own Errors556554536

ContentsLogging Errors Gracefully557Logging Errors to a Log FileNext56056027 Building User Authentication and PersonalizationSolution Components561User Identification and PersonalizationStoring Bookmarks563563Implementing the Database565Implementing the Basic Site566Implementing User AuthenticationRegistering UsersLogging InLogging Out562563Recommending BookmarksSolution Overview561569569575579Changing Passwords580Resetting Forgotten Passwords582Implementing Bookmark Storage and RetrievalAdding Bookmarks588Displaying BookmarksDeleting Bookmarks587590591Implementing Recommendations594Considering Possible Extensions59828 Building a Web-Based Email Service with Laravel Part IWeb Edition29 Building a Web-Based Email Service with Laravel Part IIWeb Edition30 Social Media Integration Sharing and Authentication31 Building a Shopping CartWeb EditionVI: AppendixA Installing Apache, PHP, and MySQL599Installing Apache, PHP, and MySQL Under UNIXBinary InstallationSource Installation600600601Basic Apache Configuration Modifications608Web Editionxxv

xxviContentsIs PHP Support Working?Is SSL Working?610610Installing Apache, PHP, and MySQL for Windows and Mac OS XUsing All-in-One Installation Packages 612Installing PEAR613Installing PHP with Other Web ServersIndex615614

Lead AuthorsLaura Thomson is Director of Engineering at Mozilla Corporation. She was formerly a principalat both OmniTI and Tangled Web Design, and she has worked for RMIT University and theBoston Consulting Group. She holds a Bachelor of Applied Science (Computer Science) degreeand a Bachelor of Engineering (Computer Systems Engineering) degree with honors. In herspare time she enjoys riding horses, arguing about free and open source software, and sleeping.Luke Welling is a software engineer and regularly speaks on open source and web developmenttopics at conferences such as OSCON, ZendCon, MySQLUC, PHPCon, OSDC, and LinuxTag.He has worked for OmniTI, for the web analytics company Hitwise.com, at the database vendorMySQL AB, and as an independent consultant at Tangled Web Design. He has taught computerscience at RMIT University in Melbourne, Australia, and holds a Bachelor of Applied Science(Computer Science) degree. In his spare time, he attempts to perfect his insomnia.Contributing AuthorsJulie C. Meloni is a software development manager and technical consultant living inWashington,D.C. She has written several books and articles on web-based programminglanguages and database topics, including the bestselling Sams Teach Yourself PHP, MySQLand Apache All in One.John Coggeshall is the owner of Internet Technology Solutions, LLC—an Internet and PHPconsultancy serving customers worldwide, as well as the owner of CoogleNet, a subscriptionbased WiFi network. As former senior member of Zend Technologies’ Global Services team, hegot started with PHP in 1997 and is the author of four published books and over 100 articles onPHP technologies.Jennifer Kyrnin is an author and web designer who has been working on the Internetsince 1995. Her other books include Sams Teach Yourself Bootstrap in 24 Hours, Sams TeachYourself Responsive Web Design in 24 Hours, and Sams Teach Yourself HTML5 Mobile ApplicationDevelopment in 24 Hours.

We Want to Hear from You!As the reader of this book, you are our most important critic and commentator. We value youropinion and want to know what we’re doing right, what we could do b

PHP, and from there it continues in describing real-world projects, MySQL integration, and security issues from a project manager’s point of view. I found every bit of this book to be well organized and easy to understand.” —notepad on codewalkers.com “A top-notch reference for programmers using PHP