May 28

php for dynamic web pages

 

CONTENTS
WHY USE PHP? 1
USING PHP ON APACHE AND UNIX 2
The php Extension 2
PHP CODE 3
Functions 3
Containers 3
PHP With Forms 4
POST and GET 5
Conditional HTML 6
PHP With E-Mail 8
A Note About Email 9
PHP With Files 9
Error Reporting 11
Write Access 11
Arrays 12
Accessing Array Data 13
Don’t Trust Anyone Outside 14
Sorting Arrays 15
Visitor Sessions 15
Requiring Cookies 17
Sessions and Security 17
The Program So Far 17
Creating Images On the Fly 18
Creating Your Own Functions 20
Optional Arguments 22
WORKING WITH MYSQL 24
Create the table 24
Create the Database 24
Create the Username and Password 24
Create the Table 24
Store the data 25
Display the data 26
CURLY BRACKETS 28
GNU FREE DOCUMENTATION LICENSE 29
0. Preamble 29
1. Applicability and Definitions 29
2. Verbatim Copying 30
3. Copying in Quantity 30
4. Modifications 31
5. Combining Documents 32
6. Collections of Documents 32
7. Aggregation With Independent Works 32
8. Translation 32
9. Termination 33
10. Future Revisions of this License 33
PHP: HYPERTEXT PROCESSOR 34

34
WHY USE PHP?
If you need to embed dynamic text into static text, you’ll find PHP extremely useful. It was
designed for this, and it excels at it. PHP is also very useful for integrating web pages with
databases.
The PHP scripting language resembles JavaScript, Java, and Perl, These languages all share a
common ancestor, the C programming language.
PHP is most different from JavaScript and Java. PHP is a server-side scripting language. All of
the “work” is done on the server. JavaScript (and Java) generally run on the client. They have
little access to the information that the server has, and mediated access to information on the
client. They can do lots of things on the client that PHP cannot. PHP has full access to the
information that the server has, and very little access to information that the client has. In fact, it
only has information that the client tells the server and that the server passes on to PHP. Because
it is on the server, however, PHP cannot be modified by the client. While you cannot necessarily
trust the information that the client gives to PHP, you can trust that your PHP is doing what you
told it to do. Because PHP is on the server end, your PHP scripts can affect your server—such as
by keeping an activity log or updating a database.
PHP and Perl often work side-by-side. These are both server-side. Where PHP excels at
embedding dynamic content, Perl excels at modifying (or “filtering”) streams of text. PHP excels
at putting things into documents, and Perl excels at finding things in documents. After you have
learned PHP, you may well find Perl useful for many tasks, especially for command-line tasks.
PHP has an advantage over Perl on most web sites because PHP is usually loaded as part of the
web server. When scripting languages “run”, the system has to first load the “interpreter” and
then “compile” the language into code that the machine can understand. When you tell PHP to
echo the current time to the web page, the computer needs to have your command translated into
numbers that it can understand. Because the PHP interpreter is already loaded as part of the web
server’s software, it is always running. This cuts out half of that process. The interpreter is
already loaded, and it can go directly to compiling the language into code. When web servers see
a request to run a Perl script, they usually have to first load the Perl interpreter. This happens
very quickly, but when there are thousands or tens of thousands of requests coming every
second, every “very quickly” can add up.
C programs are “pre-compiled”. They cut out both steps in that process: no interpreter is needed
because the program is already compiled into code the machine understands. Because of this,
however, C programs must be compiled every time you switch to a new machine. If you move to
a different host, you will usually have to recompile your C programs. Sometimes you’ll even
have to recompile your C programs when your ISP upgrades their server’s system software. And
many ISPs do not provide you with a C compiler. You’ll find that PHP is more “portable” than C
in this respect: if it works on one server, it will usually work on any other server that has it. Most
ISPs that provide server-side scripting provide PHP.

Download PDF

May 25

PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide

Editorial Reviews

Product Description

It hasn’t taken Web developers long to discover that when it comes to creating dynamic, database-driven Web sites, MySQL and PHP provide a winning open source combination. Add this book to the mix, and there’s no limit to the powerful, interactive Web sites that developers can create. With step-by-step instructions, complete scripts, and expert tips to guide readers, veteran author and database designer Larry Ullman gets right down to business: After grounding readers with separate discussions of first the scripting language (PHP) and then the database program (MySQL), he goes on to cover security, sessions and cookies, and using additional Web tools, with several sections devoted to creating sample applications. This guide is indispensable for intermediate- to advanced level Web designers who want to replace their static sites with something dynamic. In this edition, the bulk of the new material covers the latest versions of both technologies: PHP 6 (due out in 2008) and MySQL 5 (available now). The book’s publication date is likely to beat the official release of PHP 6, making it one of the first books available on the subject.

From the Author

This is the third edition of the fourth book I wrote and it continues to be my most popular. In this book I teach how to use the two most important server-side technologies–PHP and MySQL–to begin creating dynamic Web sites today.

The book teaches everything you need to know to create real-world Web applications, from the fundamentals of PHP, SQL, and MySQL, to more complex uses of all three technologies. The book does not assume previous experience with any of these, although you should already be comfortable with HTML. I will say that this book, considering all the content involved, goes at a fairly quick pace. If you have less computer, Web development, or programming experience, you may be better served by my “PHP for the Web: Visual QuickStart Guide” book, which goes more deliberately and explains things in smaller chunks.

When I wrote the book, PHP 6 was about half-way complete, so I was able to use a beta version of PHP 6. For somewhat complicated reasons, PHP 6 has since died and its status is still uncertain. Still, I can recommend the book in good conscience, as only a few pages of one chapter require PHP 6, and that content is clearly marked (actually, most of that content can be replicated in PHP 5, just using different code). As with all my books, if you ever have problems with or questions about any code, you can always get a direct answer from me via email or, preferably, using my online support forums.

In March of 2011, I begin writing the fourth edition of this book, due out in August 2011.

Thanks for your interest in the book. It is appreciated. And if you purchase it, I hope you like it and find it to be useful and informative.

From the Back Cover

Visual QuickPro Guide–the fast, efficient way to learn!

  • Easy visual approach uses pictures to guide you through PHP 6 and MySQL 5 and show you what to do.
  • Concise steps and explanations let you get up and running in no time.
  • Page for page, the best content and value around.
  • Companion Web site at contains complete source code for examples in the book, online resources, extra scripts, updates, a reader forum, and more.

About the Author

Larry Ullman is a writer, Web and software developer, trainer, instructor, speaker, and consultant. He has written 19 books and numerous articles. His books have sold over 300,000 copies world wide in more than 20 languages. As his readers, students, and co-workers can attest, Larry’s strength is in translating geek into English: converting the technical and arcane into something comprehensible and useful.
May 21

PHP Solutions: Dynamic Web Design Made Easy

Editorial Reviews

Product Description

This is the second edition of David Power’s highly-respected PHP Solutions: Dynamic Web Design Made Easy. This new edition has been updated by David to incorporate changes to PHP since the first edition and to offer the latest techniques–a classic guide modernized for 21st century PHP techniques, innovations, and best practices.

You want to make your websites more dynamic by adding a feedback form, creating a private area where members can upload images that are automatically resized, or perhaps storing all your content in a database. The problem is, you’re not a programmer and the thought of writing code sends a chill up your spine. Or maybe you’ve dabbled a bit in PHP and MySQL, but you can’t get past baby steps. If this describes you, then you’ve just found the right book. PHP and the MySQL database are deservedly the most popular combination for creating dynamic websites. They’re free, easy to use, and provided by many web hosting companies in their standard packages.

Unfortunately, most PHP books either expect you to be an expert already or force you to go through endless exercises of little practical value. In contrast, this book gives you real value right away through a series of practical examples that you can incorporate directly into your sites, optimizing performance and adding functionality such as file uploading, email feedback forms, image galleries, content management systems, and much more. Each solution is created with not only functionality in mind, but also visual design.

But this book doesn’t just provide a collection of ready-made scripts: each PHP Solution builds on what’s gone before, teaching you the basics of PHP and database design quickly and painlessly. By the end of the book, you’ll have the confidence to start writing your own scripts or–if you prefer to leave that task to others–to adapt existing scripts to your own requirements. Right from the start, you’re shown how easy it is to protect your sites by adopting secure coding practices.

From the Author

What made the first edition of “PHP Solutions” my most popular book was that I wrote it with PHP 5 in mind at a time when most websites were still hosted on PHP 4 servers. So, when friends of ED asked me to prepare a second edition, I thought it would be a simple task — just remove the PHP 4 material, and add some new techniques. How wrong I was!

The decision to drop support for PHP 4 was liberating. I realized that some tasks, such as uploading files and creating thumbnails, could be much better handled by custom classes. I hadn’t been able to do that in the first edition because classes in PHP 4 and PHP 5 are mutually incompatible. The classes break complex tasks into simple, easy-to-understand operations. Better still, all the code is project-neutral, so you can reuse the classes in other websites by writing no more than a dozen lines of code — sometimes less.

Although the book retains the original structure of the first edition, all the code has been completely rewritten, making it cleaner and more efficient. Other new features include displaying the results of a news feed using SimpleXML and the Standard PHP Library (SPL). There’s also detailed coverage of the date and time classes introduced in PHP 5.2 and 5.3. The chapter on working with multiple database tables has been expanded to explain how to implement foreign key constraints in InnoDB, the default storage engine in MySQL 5.5.

This new edition requires PHP 5.2 and MySQL 4.1 or later. The code won’t work in earlier versions.

From the Back Cover

What you’ll learn
  • Updates to the first edition with the latest PHP techniques for modern, dynamic web design
  • Create dynamic websites with design and usability in mind, as well as functionality
  • Understand how PHP scripts work, giving you confidence to adapt them to your own needs
  • Bring online forms to life, check required fields, and ensure user input is safe to process
  • Upload files and automatically create thumbnails from larger images
  • Manage website content with a searchable database

Who this book is for

This is a “must have” reference book for any Web developer using PHP scripting language. If you have read the first edition classic, then this update will bring you the latest PHP techniques and best practices. If you are new to dynamic web design with PHP, then David will introduce you to the core techniques and methods for dynamic PHP web sites, ready for the 21st century!

About the Author

David Powers is the author of a series of highly successful books on PHP, Dreamweaver, and web development. He began developing websites in 1994 when – as Editor, BBC Japanese TV – he needed a way to promote his fledgling TV channel, but didn’t have an advertising budget. He persuaded the IT department to let him have some space on the BBC’s server, and hand-coded a bilingual website from scratch. That experience ignited a passion for web development that consumes him to this day.

After a career spanning three decades in radio and TV news, David left the BBC in 1999 to work independently, and developed an online system with PHP and MySQL to deliver daily economic and political analysis in Japanese for the clients of a leading international consultancy. Since 2004, he has devoted most of his time to writing books and teaching web development. His clear writing style is valued not only in the English-speaking world; several of his books have been translated into Spanish and Polish.

David is an Adobe Community Professional and Adobe Certified Instructor for Dreamweaver. In 2010, he became one of the first people to qualify as a PHP 5.3 Zend Certified Engineer.

May 18

Learning PHP, MySQL, and JavaScript (Animal Guide)

Editorial Reviews

Review

“Just get this book… [it] will work like a miracle for you.” – Abdul Khan –Amazon Canada

Excellent! Easy to read, straightforward guide. Already learned several very useful things.” – Holly –Good Reads

Finally a comprehensive resource for HTML users who want to move to the next level, and implement data-driven access to their websites.” – Michael L. Kleper –The Kleper Report

“After the first chapter of introducing terms; I knew that I had to purchase this book.” – Graysen –Greysen Oh’s Blog

This is a superb start for learning the ins and outs of PHP, MySQL and JavaScript.” – Jonny IT Guy –Amazon UK

Product Description

If you know HTML, this guide will have you building interactive websites quickly. You’ll learn how to create responsive, data-driven websites with PHP, MySQL, and JavaScript, regardless of whether you already know how to program. Discover how the powerful combination of PHP and MySQL provides an easy way to build modern websites complete with dynamic data and user interaction. You’ll also learn how to add JavaScript to create rich Internet applications and websites.

Learning PHP, MySQL, and JavaScript explains each technology separately, shows you how to combine them, and introduces valuable web programming concepts, including objects, XHTML, cookies, and session management. You’ll practice what you’ve learned with review questions in each chapter, and find a sample social networking platform built with the elements introduced in this book.

This book will help you:

  • Understand PHP essentials and the basics of object-oriented programming
  • Master MySQL, from database structure to complex queries
  • Create web pages with PHP and MySQL by integrating forms and other HTML features
  • Learn about JavaScript, from functions and event handling to accessing the Document Object Model
  • Use libraries and packages, including the Smarty web template system, PEAR program repository, and the Yahoo! User Interface Library
  • Make Ajax calls and turn your website into a highly dynamic environment
  • Upload and manipulate files and images, validate user input, and secure your applications

From the Author

Having developed for the Internet since the mid 1990s I have used a number of programming languages, beginning with Perl, which was the first tool I mastered. However I soon found that great though Perl was for developing with, at the time it didn’t have the power I needed for ultra busy websites, and so the load averages of the servers I used was going through the roof.

So I rewrote all the processor-intensive code in C and was able to substantially slow down our server acquisition rate. But while C is powerful, it takes a lot of coding to replicate even basic Perl functions. So when PHP came along I was very pleasantly surprised to discover that even though it is interpreted (that is, re-compiled each time it is run), it placed far less of a strain on the servers than Perl, and also took up far less development time.

Since then I have used PHP in combination with MySQL for all my server side development. And with JavaScript gaining the XMLHttpRequest object, and hence the beginnings of Ajax, the three technologies are now my mainstays for web development.

So when O’Reilly asked me to write this book I jumped at the opportunity. In it I have tried to take you from first steps, without assuming any prior knowledge other than basic HTML and maybe some CSS, through each of the technologies in turn, and along the way point out the shortcuts and pitfalls I have discovered, to give you the headstart I didn’t have.

I maintain an active discussion forum on the book’s topics, which is linked to via the companion website at lpmj.net, and am always happy to answer any questions you may have.

About the Author

Robin Nixon has worked with and written about computers since the early 1980s (his first computer was a Tandy TRS 80 Model 1 with a massive 4KB of RAM!). One of the web sites he developed presented the world’s first radio station licensed by the music copyright holders. In order to enable people to continue to surf while listening, Robin also developed the first known pop-up windows.

Robin has worked for many of Britain’s main IT magazine publishers where he has held several roles including editorial, promotions, and cover disc editing. He is the author of over 500 magazine articles and eight books on computing.

Product Details

  • Paperback: 528 pages
  • Publisher: O’Reilly Media; 1 edition (July 21, 2009)
  • Language: English
  • ISBN-10: 0596157134
  • ISBN-13: 978-0596157135
  • Product Dimensions: 9.1 x 7.1 x 1 inches
May 18

PHP and MySQL Web Development (4th Edition)

<a href=”http://phpfly.net/wp-content/uploads/2011/05/2.jpg”>

Editorial Reviews

Amazon.com Review

The PHP server-side scripting language and the MySQL database management system (DBMS) make a potent pair. Both are open-source products–free of charge for most purposes–remarkably strong, and capable of handling all but the most enormous transaction loads. Both are supported by large, skilled, and enthusiastic communities of architects, programmers, and designers. PHP and MySQL Web Development introduces readers (who are assumed to have little or no experience with the title subjects) to PHP and MySQL for the purpose of creating dynamic Internet sites. It teaches the same skills as introductory Active Server Pages (ASP) and ColdFusion books–technologies that address the same niche.Authors Luke Welling and Laura Thomson’s technique aims to get readers going on their own projects as soon as possible. They present easily digestible sections on specific technical processes–”Accessing array contents” and “Using encryption with PHP” are two examples. Each section centers on a sample program that strips the task at hand down to its essentials, enabling the reader to fit the process into his or her own solutions as required. Tables that list options and other nuggets of reference material appear as well, but the many examples and the authors’ commentary on them take center stage.

For reference material on MySQL, have a look at Paul DuBois’s MySQL. On the PHP side, Web Application Development with PHP 4.0 is excellent. –David Wall

Topics covered:

  • The MySQL database server (for both Unix and Windows)
  • Accessing MySQL databases through PHP scripting (the letters don’t really stand for anything)
  • Database creation and modification
  • PHP tricks in order of increasing complexity–everything from basic SQL queries to secure transactions for commerce
  • Authentication
  • Network connectivity
  • Session management
  • Content customization

–This text refers to an alternate Paperback edition.

Review

“This book by Welling & Thomson is the
only one which I have found to be indispensable.
The writing is clear and straightforward
but never wastes my time.The book is
extremely well laid out.The chapters are the
right length and chapter titles quickly take
you where you want to go.”
—Wright Sullivan, President,A&E
Engineering, Inc., Greer South Carolina

“There are several good introductory
books on PHP, but Welling & Thomson is an
excellent handbook for those who wish to
build up complex and reliable systems. It’s
obvious that the authors have a strong background
in the development of professional
applications and they teach not only
the language itself, but also how to use it
with good software engineering practices.”
—Javier Garcia, senior telecom engineer,
Telefonica R&D Labs, Madrid

“This book rocks! I am an experienced
programmer, so I didn’t need a lot of help
with PHP syntax; after all, it’s very close to
C/C++. I don’t know a thing about
databases, though, so when I wanted to
develop a book review engine (among
other projects) I wanted a solid reference
to using MySQL with PHP. I have
O’Reilly’s mSQL and MySQL book, and
it’s probably a better pure-SQL reference,
but this book has earned a place on my
reference shelf…Highly recommended.”
—Paul Robichaux

“The true PHP/MySQL bible, PHP
and MySQL Web Development by Luke
Welling and Laura Thomson, made me
realize that programming and databases are
now available to the commoners. Again, I
know 1/10000th of what there is to know,
and already I’m enthralled.”
—Tim Luoma,TnTLuoma.com

Product Details

  • Paperback: 1008 pages
  • Publisher: Addison-Wesley Professional; 4 edition (October 11, 2008)
  • Language: English
  • ISBN-10: 9780672329166
  • ISBN-13: 978-0672329166
  • ASIN: 0672329166
  • Product Dimensions: 8.9 x 7 x 2.2 inches

Link:http://www.amazon.com/PHP-MySQL-Web-Development-4th/dp/0672329166/ref=sr_1_1?s=books&ie=UTF8&qid=1305333788&sr=1-1

May 14

Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems

Editorial Reviews

Product Description

PHP is an easy-to-use scripting language perfect for quickly creating the Web features you need. Once you know the basics of how the language works, wouldn’t it be great to have a collection of useful scripts that solve those tricky problems and add interesting functionality to your site? We thought so, too.

Instead of starting at “Hello World,” Wicked Cool PHP assumes that you’re familiar with the language and jumps right into the good stuff. After you learn the FAQs of life-the most commonly wished for PHP scripts-you’ll work your way through smart configuration options and the art of forms, all the way through to complex database-backed scripts.

Wicked Cool PHP contains a wide variety of scripts to process credit cards, check the validity of email addresses, template HTML, and serve dynamic images and text. The 76 easily implemented scripts will also teach you how to:

Send and receive email notifications Track your visitors’ behavior with cookies and sessions Override PHP’s default settings Manipulate dates, images, and text on the fly Harness SOAP and other web services Create an online poll, ecard delivery system, and blogBut it’s not all fun and games: Security is a big concern when programming any web application. So you’ll learn how to encrypt your confidential data, safeguard your passwords, and prevent common cross-site-scripting attacks. And you’ll learn how to customize all of the scripts to fit your own needs.

Dynamic Web content doesn’t have to be difficult. Learn the secrets of the craft from two experienced PHP developers with Wicked Cool PHP.

About the Author

William Steinmetz is the author of LAN Party: Hosting the Ultimate Frag Fest (Wiley) and co-author of Paint Shop Pro for Dummies (IDG). He is the webmaster and editor of StarCityGames.com, where traffic has quadrupled as a result of the changes he designed and implemented, all using PHP.

Product Details

  • Paperback: 224 pages
  • Publisher: No Starch Press; 1 edition (February 16, 2008)
  • Language: English
  • ISBN-10: 9781593271732
  • ISBN-13: 978-1593271732
  • ASIN: 1593271735
  • Product Dimensions: 9.1 x 7.1 x 0.6 inches

Link:http://www.amazon.com/Wicked-Cool-PHP-Real-World-Difficult/dp/1593271735/ref=sr_1_11?s=books&ie=UTF8&qid=1305328607&sr=1-11

Apr 24

PHP 5 Power Programming(pdf)

Editorial Reviews

From the Back Cover

“This book, written by my colleague, Andi Gutmans, and two very prominent PHP developers, Stig Bakken and Derick Rethans, holds the key to unlocking the riches of PHP 5. It thoroughly covers all of the features of this new version, and is a must have for all PHP developers interested in exploring PHP 5′s advanced features”

—Zeev Suraski, Co-Designer of PHP 5 and Co-Creator of the Zend Engine

  • Expert PHP 5 programming techniques, direct from PHP 5 co-creator and key developers
  • Definitive coverage of the PHP object model, design patterns, XML/SOAP integration, and more
  • Solid introduction and expert insights into performance tuning, PEAR, extensions, and database access
  • The definitive introduction to PHP 5′s advanced features!
  • The definitive introduction for today’s most powerful PHP 5 techniques

In this book, PHP 5′s co-creator and two leading PHP developers show you how to make the most of PHP 5′s industrial-strength enhancements in any project—no matter how large or complex. Their unique insights and realistic examples illuminate PHP 5′s new object model, powerful design patterns, improved XML Web services support, and much more. Whether you’re creating web applications, extensions, packages, or shell scripts—or migrating PHP 4 code—here are high-powered solutions you won’t find anywhere else.

Review PHP’s syntax and master its object-oriented capabilities—from properties and methods to polymorphism, interfaces, and reflection

  • Master the four most important design patterns for PHP development
  • Write powerful web applications: handle input, cookies, session extension, and more
  • Integrate with MySQL, SQLite, and other database engines
  • Provide efficient error handling that’s transparent to your users
  • Leverage PHP 5′s improved XML support—including parsing, XSLT conversions, and more
  • Build XML-based web services with XML-RPC and SOAP
  • Make the most of PEAR: work with the repository, use key packages, and create your own
  • Upgrade PHP 4 code to PHP 5—compatibility issues, techniques, and practical workarounds
  • Improve script performance: tips and tools for PHP optimization
  • Use PHP extensions to handle files/streams, regular expressions, dates/times, and graphics
  • Create original extensions and shell scripts

If you’re a software developer new to PHP, you’ll leap quickly into PHP and its new object-oriented capabilities. If you’re an experienced PHP programmer, you already recognize PHP’s convenience and simplicity. Now, discover all of its extraordinary power!

ABOUT THE SOFTWARE

At this book’s link to Zend.com, download a fully functional 90-day version of Zend Studio, today’s breakthrough tool for developing, managing, and debugging PHP code.

Series Editor Bruce Perens’ is an open source evangelist, developer, and consultant whose software is a major component of most commercial embedded Linux offerings. He founded or cofounded Linux Standard Base, Open Source Initiative, and Software in the Public Interest. As Debian GNU/Linux Project Leader, he was instrumental in getting the system on two U.S. space shuttle flights.
© Copyright Pearson Education. All rights reserved.

About the Author

ANDI GUTMANS co-created PHP 3 and all versions since. A member of the PHP core team, he is one of the world¿s most highly regarded PHP developers.

STIG SÆTHER BAKKEN, also a member of the PHP core team, created PEAR: PHP Extension and Application Repository, the framework and global distribution system for reusable PHP components. Gutmans and Bakken are members of the PHP Hall of Fame.

DERICK RETHANS is a PHP code contributor and leader of the PHP QA team.

Apr 24

PHP Reference Book

 If you want to get a copy of the book in PDF form, it is available for free by simply clicking the link: download the PDF version.
 
Enjoyed the book? Consider writing a review and help others find the book!
 
Why are you giving it away for FREE? I get asked that a lot, and the simple truth is that most people are looking for a book like this not just for a digital copy of the book’s content, but for the actual physical book.

Giving away a PDF version serves three purposes:

  1. Provides a digital copy of the book for owners of a physical copy
  2. Allows people wanting to preview the book to get more than just a few pages. Don’t get me wrong, I am thankful for every copy of the book sold, but as a consumer I would rather know that the book I’m spending my money on is what I am looking for rather than wasting my money if it isn’t the right fit.
  3. Gets the book in more hands than I would simply selling a physical copy. It’s ridiculous (except to groups like the RIAA) to assume that everyone who downloads the PDF version would have bought a copy of the book if there wasn’t a free version available.

 
20,000+ downloads of the free PDF already!