Get Organized. Get Focused. Get Moving. PDF Free Download

Goodreads helps you keep track of books you want to read.
Start by marking “Get Organized. Get Focused. Get Moving.” as Want to Read:
Rate this book

See a Problem?

We’d love your help. Let us know what’s wrong with this preview of Get Organized. Get Focused. Get Moving. by Cynthia Kyriazis.

Need to become more organized and focused to achieve your goals faster? These printable and iPad-friendly goal setting worksheets are designed to help you structure your goals, make the roadmap crystal clear and track each step towards new accomplishments easily. Download them now and become more productive and accomplished then ever before in your life by setting short-term, mid-term and long. Free Home Management Binder. From New Bee Homeschooler. Looking for a way to get a few aspects in your life put together in a more organized way in this upcoming year? With over 35 forms (and growing), this free home management binder will help you organize many areas of your home—finances, housekeeping, meals, projects, and more. Notion is your all-in-one workspace, where you can write, plan, collaborate and get organized. Take notes, keep databases, build a wiki, project manage your team — all with one tool. We launched Notion Web Clipper so you can save any page on the web to your Notion workspace. “No other program has made me more eager to get rid of so much stuff that I wasn't even using. I've never felt so good, light & free. I'm loving this clutter-free life so much.” —Mary “This program is a life changer.” “Alejandra provides organizing information that I have not heard or read before. Her concept is brilliant. † Biology 101 — get the lowdown on how life is studied and open a window on the world’s organisms † Jump into the gene pool — discover how cell reproduction and genetics work, from making sense of Mendel’s Law of Segregation to dealing with DNA † Explore the living world — find out how ecology and evolution.

Not the book you’re looking for?

Preview — Get Organized. Get Focused. Get Moving. by Cynthia Kyriazis

Disorganization leads to missed deadlines and opportunities....
Missed deadlines and opportunities lead to a decline in performance....
Declined performance oftentimes leads to financial losses and STRESS....

Are your business goals being realized to their full potential?? Or are they falling into productivity potholes?
Cynthia Kyriazis shares with you the best organizatio
Published January 11th 2016 by Incorgnito Publishing Press
To see what your friends thought of this book,please sign up.
To ask other readers questions aboutGet Organized. Get Focused. Get Moving.,please sign up.

Be the first to ask a question about Get Organized. Get Focused. Get Moving.

This book is not yet featured on Listopia.Add this book to your favorite list »
Rating details

Jan 04, 2016Jay rated it really liked it
A new book taking on productivity issues through better organizational skills. There seem to be quite a few of these books that focus on a particular aspect of organizing. “Get Organized, Get Focused, Get Moving” doesn’t limit itself to any one aspect. The book fooled me initially – written by an author who organizes offices, many of the bad examples she shows and talks about were offices covered with piles of paper (which I am intimately familiar with). The author divides the world into differe...more
Jan 29, 2016Louis Prosperi rated it really liked it
An easy to read and helpful guide to improving your organizational and time management skills.
This book offers advice on how to become better organized and more productive. The author uses lots of examples from her experience as a consultant. The writing style is very casual, and the author does a good job of keeping the reader's interest.
The first section of the book focuses on organization, including how to organize your office, your desk, and your computer. There was a lot of emphasis on org
Jan 13, 2016Karin rated it really liked it
I received an advance copy of this book in return for an honest review. I know that I can not be fully biased as that is not how 'free stuff' psychologically works, but I will do my best.
I have been an avid follower of GTD for years. I reread the original book every once in a while to remind myself and get recentered. I thought I needed that because the system was perfect, but any lapses were user error. This book reminded me that not one system is going to work for every person. she had many su
Jun 03, 2016Fatimah rated it it was amazing
Shelves: giveaways
I have received this book in exchange for an honest review.
Cynthia Kyriazis is a master mind! Literally. I am a big fan of being organized but I felt like I needed this book to become MORE organized in different ways and this book definitely helps! My favorite tip that I have gained from this book is how to keep and let go of paper. I had a ton of paper in an organized fashion but I always wanted to get rid of it but didn't know how. I recommend this book to everyone especially people who want t
*Note: I received a free PDF of this book to review.*
This book is more of an overview of ideas for organizing than a coherent, self-contained system. Many of the tips I'd read elsewhere; if you've read other books on organizing, this might not be worthwhile for you. I did get some useful ideas from this book, and I liked how she gave a list of three things you can do to put that chapter's advice into action and asks you to write down one thing you're going to do differently.
Quibbles I had with
Get Organized. Get Focused. Get Moving.; Cynthia Kyriazis. 7/2/2016-7/22/2016.
'The goal is not to be perfect by the end. The goal is to be better today,' Simon Sinek
The best thing I Love about this book is it is very fundamental. Weather you are a VP or GM of a large corporation or a college student who works part time, this book is an easy read and simple to apply. I'm am convinced that duplication within any organization happens either in a positive or a negative way. Because of the fundamenta
In the mobile world in which so many of us live - one of constant connection and perpetual demands - this work is for you. If you are juggling two careers, as so many small business owners do - one out of necessity and the other out of your passions - and there is never enough time to do all that is required, then read this book. Or, if you are just a disorganized procrastinator and need help, then 'Get Organized. Get Focused. Get Moving.' is a MUST read for you. The author, Cynthia Kyriazis, a ...more
Jan 23, 2016Christi rated it liked it
*I received a free copy of this book to review. The opinions are my own.
I enjoyed reading this book. The book is broken up into two main parts--organization and time management. A lot of it was pretty basic stuff--but looking at the pictures of people she has helped I guess that's where you have to start sometimes :) I enjoyed reading about the basic principles behind what she had to say, and she definitely has a 'take what works for you' attitude that was nice. There were a few times I felt lik
Feb 24, 2016Elizabeth Ehlen rated it it was amazing
Are you good at what you do but not good at managing the business side of it? Or is something holding you back from moving up to the next level in your business, but you can’t put your finger on what the roadblock is?
Enter Cynthia Kyriazis, professional organizer and motivator. In Get Organized, Get Focused, Get Moving. Kyriazis breaks down the basics of organizing as it relates to productivity in your business. Her advice works whether you are a solopreneur or manage a large department in a Fo
This is the perfect book for the unorganized!! I am a big fan of getting organized and time management. This book gave me great ideas on how to better manage my time. I loved how each chapter ended with notes from the author on things that are important in the chapter as well as a place for the reader to make a note of things they would like to implement from that chapter. It gives you a chance to pause and reflect on what you have read.
Highly recommend!! This is a great read for those that need
Terry Pearson rated it really liked it
Feb 06, 2016
Cecilia Dunbar Hernandez rated it it was amazing
Feb 20, 2016
Susan K Spaulding rated it it was amazing
Mar 02, 2016
Frederick Rotzien marked it as to-read
Feb 06, 2016
There are no discussion topics on this book yet.Be the first to start one »
Recommend ItStatsRecent Status Updates
See top shelves…
Cynthia Kyriazis is a national productivity coach, strategist, and trainer. She has been improving efficiency and productivity for Fortune 500, corporate, and small business clients with Kansas City-based, Productivity Partners, Inc., since 1992.
Kyriazis released her second book, Get Organized. Get Focused. Get Moving. in February 2016. The book addresses how to overcome the productivity poth
Luvvie Ajayi Jones—author, cultural critic, digital entrepreneur—might be best described as a professional truthteller. Her crazily popular...
54 likes · 0 comments
Advance Praise for Head First PHP & MySQL “PHP and MySQL are two of today’s most popular web development technologies, and this book shows readers why. Building a site without them is now as unthinkable as doing web design without CSS. This book is a great introduction and is laugh-out-loud funny. It’s the book I wish I had learned from.” — 0007Harvey Quamen, Associate Professor of English and Humanities Computing, University of Alberta “Everything we’ve come to accept about the drudgery of technical learning has been abandoned and in its place an unusually fun method for learning is created. I have full confidence that the Head First series will revolutionize the technical publishing industry, and that these new methods will be the eventual standard. I bet my tech-phobic grandmother could pick up PHP and MySQL techniques after a single reading. She’d probably even have a good time doing it!” — 0007Will Harris, Database Administrator, Powered By Geek “Reading Head First PHP & MySQL is like taking a class from the ‘cool’ teacher. It makes you look forward to learning.” — 0007Stephanie Liese, Web Developer “Using images and humor the book is easy to digest and yet delivers real technical know-how.” — 0007Jereme Allen, Web Developer “‘After a challenging, high-speed read-through and lots of quirky “Do This” projects, such as “My dog was abducted by aliens” and the “Mismatch Dating Agency,” I can’t wait to add some real PHP power to my web sites.” — 0007David Briggs, Software Engineer and Technical Author
Praise for Head First HTML with CSS & XHTML “Eric and Elisabeth Freeman clearly know their stuff. As the Internet becomes more complex, inspired construction of web pages becomes increasingly critical. Elegant design is at the core of every chapter here, each concept conveyed with equal doses of pragmatism and wit.” — 0007Ken Goldstein, Executive Vice President & Managing Director, Disney Online “The Web would be a much better place if every HTML author started off by reading this book.” — L. David Baron, Technical Lead, Layout & CSS, Mozilla Corporation, “I’ve been writing HTML and CSS for ten years now, and what used to be a long trial and error learning process has now been reduced neatly into an engaging paperback. HTML used to be something you could just hack away at until things looked okay on screen, but with the advent of web standards and the movement towards accessibility, sloppy coding practice is not acceptable anymore... from a business standpoint or a social responsibility standpoint. Head First HTML with CSS & XHTML teaches you how to do things right from the beginning without making the whole process seem overwhelming. HTML, when properly explained, is no more complicated than plain English, and the Freemans do an excellent job of keeping every concept at eye-level.” — 0007Mike Davidson, President & CEO, Newsvine, Inc. “Oh, great. You made an XHTML book simple enough a CEO can understand it. What will you do next? Accounting simple enough my developer can understand it? Next thing you know we’ll be collaborating as a team or something.” —Janice Fraser, CEO, Adaptive Path “This book has humor, and charm, but most importantly, it has heart. I know that sounds ridiculous to say about a technical book, but I really sense that at its core, this book (or at least its authors) really care that the reader learn the material. This comes across in the style, the language, and the techniques. Learning – real understanding and comprehension – on the part of the reader is clearly top most in the minds of the Freemans. And thank you, thank you, thank you, for the book’s strong, and sensible advocacy of standards compliance. It’s great to see an entry level book, that I think will be widely read and studied, campaign so eloquently and persuasively on behalf of the value of standards compliance in web page code. I even found in here a few great arguments I had not thought of – ones I can remember and use when I am asked – as I still am – ‘what’s the deal with compliance and why should we care?’ I’ll have more ammo now! I also liked that the book sprinkles in some basics about the mechanics of actually getting a web page live - FTP, web server basics, file structures, etc.” —Robert Neer, Director of Product Development,
Praise for Head First JavaScript “So practical and useful, and so well explained. This book does a great job of introducing a complete newbie to JavaScript, and it’s another testament to Head First’s teaching style. Out of the other JavaScript books, Head First JavaScript is great for learning, compared to other reference books the size of a phone book.” — 0007Alex Lee, Student, University of Houston “An excellent choice for the beginning JavaScript developer.” — 0007Fletcher Moore, Web Developer & Designer, Georgia Institute of Technology “Yet another great book in the classic ‘Head First’ style.” — 0007TW Scannell “JavaScript has long been the client-side engine that drives pages on the Web, but it has also long been misunderstood and misused. With Head First JavaScript, Michael Morrison gives a straightforward and easy-to-understand introduction of this language, removing any misunderstanding that ever existed and showing how to most effectively use it to enhance your web pages.” — 0007Anthony T. Holdener III, Web applications developer, and the author of Ajax: The Definitive Guide. “A web page has three parts—content (HTML), appearance (CSS), and behaviour (JavaScript). Head First HTML introduced the first two, and this book uses the same fun but practical approach to introduce JavaScript. The fun way in which this book introduces JavaScript and the many ways in which it reinforces the information so that you will not forget it makes this a perfect book for beginners to use to start them on the road to making their web pages interactive.” — 0007Stephen Chapman, Owner Felgall Pty Ltd., JavaScript editor, “This is the book I’ve been looking for to recommend to my readers. It is simple enough for complete beginners but includes enough depth to be useful to more advanced users. And it makes the process of learning fun. This might just be the only JavaScript book you ever need.” — 0007Julie L Baumler, JavaScript Editor,
Other related books from O’Reilly Learning PHP & MySQL Web Database Applications with PHP and MySQL Programming PHP Learning MySQL PHP in a Nutshell PHP CookbookTM PHP HacksTM MySQL in a Nutshell MySQL CookbookTM
Other books in O’Reilly’s Head First series Head First JavaTM Head First Object-Oriented Analysis and Design (OOA&D) Head First HTML with CSS and XHTML Head First Design Patterns Head First Servlets and JSP Head First EJB Head First PMP Head First SQL Head First Software Development Head First JavaScript Head First Ajax Head First Physics Head First Statistics Head First Rails Head First Web Design Head First Algebra
Head First PHP & MySQL Wouldn’t it be dreamy if there was a PHP & MySQL book that made databases and server-side web programming feel like a match made in heaven? It’s probably just a fantasy...
Lynn Beighley Michael Morrison
Beijing • Cambridge • K001aln • Sebastopol • Taipei • Tokyo
Head First PHP & MySQL by Lynn Beighley and Michael Morrison Copyright © 2009 O’Reilly Media, Inc. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly Media books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles ( For more information, contact our corporate/institutional sales department: (800) 998-9938 or [email protected]
Series Creators:
Kathy Sierra, Bert Bates
Series Editor:
Brett D. McLaughlin
Sanders Kleinfeld
Design Editor:
Louise Barr
Cover Designers:
Louise Barr, Steve Fehler
Production Editor:
Brittany Smith
Colleen Gorman
Julie Hawks
Page Viewers:
Julien and Drew
Michael’s nephew Julien generously lent his Superman powers to help get this book finished.
Printing History: December 2008: First Edition.
Drew is, at thi moment, installins very a new kitchen in g Lynn’s new old ho use.
The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. The Head First series designations, Head First PHP & MySQL, and related trade dress are trademarks of O’Reilly Media, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a trademark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation of this book, the publisher and the authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. No hardwood floors, UFOs, Elvis look-alikes, or virtual guitars were harmed in the making of this book. But a few broken hearts were mended thanks to some careful mismatching!
ISBN: 978-0-596-00630-3 [M]
For my parents, who frequently use web applications and are always there for me. - Lynn Beighley To Rasmus Lerdorf, who single-handedly sparked the language that would eventually become PHP as we know it now. Enduring proof that it really only takes one person to lead us all down a new, more enlightened path. - Michael Morrison
the author(s)
Author(s) of Head First PHP & MySQL Lynn Beighley
Michael Morriso
Lynn Beighley is a fiction writer stuck in a
technical book writer’s body. Upon discovering that technical book writing actually paid real money, she learned to accept and enjoy it. After going back to school to get a Masters in Computer Science, she worked for the acronyms NRL and LANL. Then she discovered Flash, and wrote her first bestseller. A victim of bad timing, she moved to Silicon Valley just before the great crash. She spent several years working for Yahoo! and writing other books and training courses. Finally giving in to her creative writing bent, she moved to the New York area to get an MFA in Creative Writing. Her Head First-style thesis was delivered to a packed room of professors and fellow students. It was extremely well received, and she finished her degree, finished Head First SQL, and just finished Head First PHP & MySQL. Whew! Lynn loves traveling, writing, and making up elaborate background stories about complete strangers. She’s a little scared of UFOs.
Michael Morrison has been an enthusiastic
contributor to the online world ever since he ran a BBS on his Commodore 64 way back when being a nerd was far less cool than it is these days. A few thousand baud later, he still marvels at how far we’ve come, and how fast. Michael doesn’t run a BBS anymore, but he’s still very much involved in the modern equivalents and the tools we use to build them. He spends most of his “official” time writing about web-related technologies, having authored or co-authored over fifty books ranging from mobile game programming to XML. He entered the Head First foray with Head First JavaScript, and hasn’t looked back. Michael is also the founder of Stalefish Labs (www., an entertainment company specializing in games, toys, and interactive media. And he’s been known to actually spend time offline (gasp!) skateboarding, playing ice hockey, and hanging out next to his koi pond with his wife, Masheed. He even sleeps every once in a while.
table of contents
Table of Contents (Summary) Intro
It’s Alive: Add Life to Your Static Pages
How It Fits Together: Connecting to MySQL
Creating Your Own Data: Create and Populate a Database
Your Application on the Web: Realistic and Practical Applications
When a Database Just Isn’t Enough: Working With Data Stored in Files
Assume They’re All Out to Get You: Securing Your Application
Remember Me?: Building Personalized Web Apps
7 ½
Sharing is Caring: Eliminate Duplicate Code
Harvesting Data: Control Your Data, Control Your World
Better Living Through Functions: String and Custom Functions
Rules for Replacement: Regular Expressions
Drawing Dynamic Graphics: Visualizing Your Data... and More!
Interfacing to the World: Syndication and Web Services
The Top Ten Topics (We Didn’t Cover): Leftovers
A Place to Play: Set Up a Development Environment
Get Even More: Extend Your PHP
Table of Contents (the real thing) Intro Your brain on PHP & MySQL. 0003 Here you are trying to learn something, while here your brain is doing you a favor by making sure the learning doesn’t stick. Your brain’s thinking, “Better leave room for more important things, like which wild animals to avoid and whether underwater yoga is a bad idea.” So how do you trick your brain into thinking that your life depends on knowing PHP and MySQL?
Who is this book for? We know what you’re thinking Metacognition Bend your brain into submission Read me The technical review team Acknowledgments
xxviii xxix xxxi xxxiii xxxiv xxxvi xxxvii
table of contents
add life to your static pages It’s Alive You’ve been creating great web pages with HTML, and a sprinkling of CSS.0003 But you’ve noticed that visitors to your site can’t do much other than passively look at the content on the pages. The communication’s one-way, and you’d like to change that. In fact, you’d really like to know what your audience is thinking. But you need to be able to allow users to enter information into a web form so that you can find out what’s on their minds. And you need to be able to process the information and have it delivered to you. It sounds as if you’re going to need more than HTML to take your site to the next level.
Have you seen him?
HTML is static and boring
PHP brings web pages to life
A form helps Owen get the whole story
Forms are made of HTML
The HTML form has problems
HTML acts on the client
PHP acts on the server
PHP scripts run on the server
Use PHP to access the form data
PHP scripts must live on a server!
The server turns PHP into HTML
A few PHP rules to code by
Finding the perfect variable name
Variables are for storing script data
$–POST is a special variable that holds form data
$–POST transports form data to your script
Creating the email message body with PH P
Even plain text can be formatted...a little
Newlines need double-quoted strings
Assemble an email message for Owen
Variables store the email pieces and parts
Sending an email message with PHP
Owen starts getting emails
Owen starts losing emails
table of contents
connecting to MySQL How it fits together Knowing how things fit together before you start building is a good idea.0003 You’ve created your first PHP script, and it’s working well. But getting your form results in an email isn’t good enough anymore. You need a way to save the results of your form, so you can keep them as long as you need them and retrieve them when you want them. A MySQL database can store your data for safe keeping. But you need to hook up your PHP script to the MySQL database to make it happen.
The new report form is great, but now I’m getting too many emails. I can’t drink enough caffeine to go through them all when I first receive them.
Owen’s PHP form works well. Too well...
MySQL excels at storing data
Owen needs a MySQL database
Create a MySQL database and table
The INSERT statement in action
Use SELECT to get table data
Let PHP handle the tedious SQL stuff
PHP lets data drive Owen’s web form
Connect to your database from PHP
Insert data with a PHP script
Use PHP functions to talk to the database
Get connected with mysqli_connect()
Build the INSERT query in PHP
Query the MySQL database with PHP
Close your connection with mysqli–close()
$–POST provides the form data
Owen needs help sifting through his data
Owen’s on his way to finding Fang
98 $query
37 seconds back in 1991 ght dunno f li they loo ts o ked like poin don ands mad ouskey h e out of t metal... th a i w me yes shot [email protected] I epres really do love potatos.
table of contents
create and populate a database Creating your own data You don’t always have the data you need. 0003 Sometimes you have to create the data before you can use it. And sometimes you have to create tables to hold that data. And sometimes you have to create the database that holds the data that you need to create before you can use it. Confused? You won’t be. Get ready to learn how to create databases and tables of your very own. And if that isn’t enough, along the way, you’ll build your very first PHP & MySQL application.
Elmer’s cu
stomer m
This is taking too long. I’d rather be spending my time imitating Elvis, not sending out emails manually.
ailing list:
Anderso n Jillian w jill_an Kevin [email protected][email protected] Newsom eckpizza. e Amanda com Garcia m aman Roundtr Ed [email protected][email protected] ee Jo0tt0msup Ann Briggs .com jojoround Ch ris @b Harte reakneckp [email protected] Lloyd boards-r Toth hovercra -us Anne [email protected] .com Wiley AnneTot [email protected] Palumbo Andrew andreww Tom iley Ryan palofmine t McKinne Alanna angrypir @mightygumba y Cla [email protected] ll.n y Meeker kneckpizz et [email protected] Ann Powers annmee Brian ker Manson [email protected] @chocoholic-in Anne Mandel [email protected] Debra bjectville Tedesco debmon .net Janis [email protected] Talwar janistede akneckpiz Vikram [email protected] Szwed [email protected] buzzcoffe Joe rbu Sherida szwedjoe n Dia @o na Snow [email protected] Edward mig Otto snowman Glenn t @tikib Hardy glenn00 Anne [email protected] Deal ctv [email protected] Mary b0tt0ms Jagel up nobigde Ann [email protected] .com Melfi dreamgir zzcoffee.c James [email protected] om Oliver eckpizza. [email protected] Lee com Parker [email protected] Anne weathero Ricci [email protected] Peter sta Reno [email protected] rbuzzcoffee.c Grace om tiki Moss [email protected] Ze lda Day [email protected] Clifford Bolger [email protected] Joyce breakneck Blunt [email protected] Anne chocoholic Bolling anneblu Lindy [email protected] Gares [email protected] breakneckpiz Fred be Jacobs [email protected] Anne bjectville .net anne99 @objectv
Big Sale!
The Elvis store is open for business
Elmer needs an application
Visualize Elmer’s application design
It all starts with a table
Make contact with the MySQL server
Create a database for Elmer’s emails
Create a table inside the database
We need to define our data
Take a meeting with some MySQL data types
Create your table with a query
USE the database before you use it
DESCRIBE reveals the structure of tables
Elmer’s ready to store data
Create the Add Email script
The other side of Elmer’s application
The nuts and bolts of the Send Email script
First things first, grab the data
mysqli_fetch_array() fetches query results
Looping for a WHILE
Looping through data with while
You’ve got mail...from Elmer!
Sometimes people want out
Removing data with DELETE
Dear Fellow Elvisonians,! Big sale this week at MakeMeEl 20% off! Genuine horse hair sideburns get one And don’t forget the “buy one, days free” leisure suits — only three left!
Use WHERE to DELETE specific data
Minimize the risk of accidental deletions
149 is a web application
table of contents
realistic and practical applications Your Application on the Web Sometimes you have to be realistic and rethink your plans. 0003 Or plan more carefully in the first place. When your application’s out there on the Web, you may discover that you haven’t planned well enough. Things that you thought would work aren’t good enough in the real world. This chapter takes a look at some real-world problems that can occur as you move your application from testing to a live site. Along the way, we’ll show you more important PHP and SQL code. Elmer has some irritated customers
Protecting Elmer from...Elmer
Demand good form data
The logic behind Send Email validation
Your code can make decisions with IF
Testing for truth
IF checks for more than just equality
The logic behind Send Email validation
PHP functions for verifying variables
Test multiple conditions with AND and OR
Form users need feedback
Ease in and out of PHP as needed
Use a flag to avoid duplicate code
Code the HTML form only once
A form that references itself
Point the form action at the script
Check to see if the form has been submitted
Some users are still disgruntled
Table rows should be uniquely identifiable
Primary keys enforce uniqueness
From checkboxes to customer IDs
Loop through an array with foreach
table of contents
working with data stored in files When a database just isn’t enough Don't believe the hype...about databases, that is.0003 Sure, they work wonders for storing all kinds of data involving text, but what about binary data? You know, stuff like JPEG images and PDF documents. Does it really make sense to store all those pictures of your rare guitar pick collection in a database table? Usually not. That kind of data is typically stored in files, and we'll leave it in files. But it's entirely possible to have your virtual cake and eat it too—this chapter reveals that you can use files and databases together to build PHP applications that are awash in binary data.
Virtual guitarists like to compete
The proof is in the picture
The application needs to store images
Planning for image file uploads in Guitar Wars
The high score database must be ALTERed
How do we get an image from the user?

Get Organized. Get Focused. Get Moving. Pdf Free Download Free

Insert the image filename into the database
Find out the name of the uploaded file
Where did the uploaded file go?
Create a home for uploaded image files
Shared data has to be shared
Shared script data is required
Think of require_once as 'insert'
Order is everything with high scores
Honoring the top Guitar Warrior
Format the top score with HTML and CSS
Only small images allowed
File validation makes the app more robust
Plan for an Admin page
Generate score removal links on the Admin page
Scripts can communicate with each other
Of GETs and POSTs
GET, POST, and high score removal
Isolate the high score for deletion
Control how much you delete with LIMIT
table of contents
securing your application Assume they’re all out to get you Your parents were right: don’t talk to strangers. 0003Or at least don’t trust them. If nothing else, don’t give them the keys to your application data, assuming they’ll do the right thing. It’s a cruel world out there, and you can’t count on everyone to be trustworthy. In fact, as a web application developer you have to be part cynic, part conspiracy theorist. Yes, people are generally bad and they’re definitely out to get you! OK, maybe that’s a little extreme, but it’s very important to take security seriously and design your applications so that they’re protected against anyone who might choose to do harm.
Good luck trying to slip any falsified documents, er high scores, by me. I’m thorough, and I rarely make mistakes.
The day the music died
Where did the high scores go?
Securing the teeming hordes
Protecting the Guitar Wars Admin page
HTTP authentication requires headers
Header Exposed
Take control of headers with PHP
Authenticating with headers
Create an Authorize script
Guitar Wars Episode II : Attack of the High Score Clones
Subtraction by addition
Security requires humans
Plan for moderation in Guitar Wars
Make room for approvals with ALTER
Unapproved scores aren’t worthy
The million-point hack
Everything in moderation...?
How exactly did she do it?
Tricking MySQL with comments
The Add Score form was SQL injected
Protect your data from SQL injections
A safer INSERT (with parameters)
Form validation can never be too smart
Cease fire!
table of contents
building personalized web apps Remember me? No one likes to be forgotten, especially users of web applications. 0003If an application has any sense of “membership,” meaning that users somehow interact with the application in a personal way, then the application needs to remember the users. You’d hate to have to reintroduce yourself to your family every time you walk through the door at home. You don’t have to because they have this wonderful thing called memory. But web applications don’t remember people automatically - it’s up to a savvy web developer to use the tools at their disposal (PHP and MySQL, maybe?) to build personalized web apps that can actually remember users.
They say opposites attract
Mismatch is all about personal data
Mismatch needs user log-ins
Prepping the database for log-ins
Constructing a log-in user interface
Encrypt passwords with SHA()
Comparing passwords
Authorizing users with HTTP
Logging In Users with HTTP Authentication
A form for signing up new users
What’s in a cookie?
Use cookies with PHP
Rethinking the flow of log-ins
A cookie-powered log-in
Logging out means deleting cookies
Sessions aren’t dependent on the client
Keeping up with session data
Renovate Mismatch with sessions
Log out with sessions
Complete the session transformation
Users aren’t feeling welcome
Sessions are short-lived...
...but cookies can last forever!
Sessions + Cookies = Superior log-in persistence
table of contents
eliminate duplicate code
Sharing is caring Umbrellas aren’t the only thing that can be shared. 0003In any web application you’re bound to run into situations where the same code is duplicated in more than one place. Not only is this wasteful, but it leads to maintenance headaches since you will inevitably have to make changes, and these changes will have to be carried out in multiple places. The solution is to eliminate duplicate code by sharing it. In other words, you stick the duplicate code in one place, and then just reference that single copy wherever you need it. Eliminating duplicate code results in applications that are more efficient, easier to maintain, and ultimately more robust. Mismatch is in pieces
Rebuilding Mismatch from a template
Rebuild Mismatch with templates

Get Organized. Get Focused. Get Moving. PDF Free Download 64 Bit

Mismatch is whole again...and much better organized
The header appears at the top of every Mismatch page, and displays the application title as well as a page-specific title.
Every Mismatch page that’s personalized to a user requires log-in code that keeps track of the user. navmenu.php
The navigation menu appears just below the header, and provides each Mismatch page with a consistent menu to navigate between the main pages.
The footer provides content along the bottom of every Mismatch page, which includes a copyright notice. index.php
With so many other scripts helping out, the index.php script is left to focus solely on its unique role, which is displaying the main user list.
table of contents
control your data, control your world Harvesting data There’s nothing like a good fall data harvest. 0003An abundance of information ready to be examined, sorted, compared, combined, and generally made to do whatever it is your killer web app needs it to do. Fulfilling? Yes. But like real harvesting, taking control of data in a MySQL database requires some hard work and a fair amount of expertise. Web users demand more than tired old wilted data that’s dull and unengaging. They want data that that that’s relevant. So what are you waiting for? Fire up your MySQL tractor and get to work!
Hate ‘em! Horror movies
Sidney’s dislike of horror movies leads to a mismatch.
A mismatch!
Love ‘em.
Horror movies
? mismatch_user user_id username password join_date first_name
response_id response
gender birthdate city state picture
user_id topic_id
mismatch_topic topic_id name category
Making the perfect mismatch
Mismatching is all about the data
Model a database with a schema
Wire together multiple tables
Foreign keys in action
Tables can match row for row
One row leads to many
Matching rows many-to-many
Build a Mismatch questionnaire
Get responses into the database
We can drive a form with data
Generate the Mismatch questionnaire form
Strive for a bit of normalcy
When normalizing, think in atoms
Three steps to a normal database
Altering the Mismatch database
So is Mismatch really normal?
A query within a query within a query...
Let’s all join hands
Connect with dots
Surely we can do more with inner joins
Nicknames for tables and columns
Joins to the rescue
Five steps to a successful mismatch
Compare users for “mismatchiness”
All we need is a FOR loop
table of contents
string and custom functions Better living through functions Functions take your applications to a whole new level. 0003 You’ve already been using PHP’s built-in functions to accomplish things. Now it’s time to take a look at a few more really useful built-in functions. And then you’ll learn to build your very own custom functions to take you farther than you ever imagined it was possible to go. Well, maybe not to the point of raising laser sharks, but custom functions will streamline your code and make it reusable. A good risky job is hard to find
The search leaves no margin for error
SQL queries can be flexible with LIKE
Explode a string into individual words
implode() builds a string from substrings
Preprocess the search string
Replace unwanted search characters
The query needs legit search terms
Copy non-empty elements to a new array
Sometimes you just need part of a string
Extract substrings from either end
Multiple queries can sort our results
Functions let you reuse code
Build a query with a custom function
Custom functions, how custom are they really?
SWITCH makes far more decisions than IF
Give build_query() the ability to sort
We can paginate our results
Get only the rows you need with LIMIT
Control page links with LIMIT
Keep track of the pagination data
Set up the pagination variables
Revise the query for paginated results
Generate the page navigation links
Putting together the complete Search script
The complete Search script, continued...
558Get Organized. Get Focused. Get Moving. PDF Free Download adobe reader for windows 10
table of contents
regular expressions Rules for replacement String functions are kind of lovable. But at the same time, they’re limited. 0003Sure, they can tell the length of your string, truncate it, change certain characters to other certain characters. But sometimes you need to break free and tackle more complex text manipulations. This is where regular expressions can help. They can precisely modify strings based on a set of rules rather than a single criterion.
my First Name: Jim ift Last Name: Sw Email: [email protected] 52 46 6 63 e: on Ph Ninja Desired Job:
Risky Jobs lets users submit resumes
Decide what your data should look like
Formulate a pattern for phone numbers

Get Organized. Get Focused. Get Moving. PDF Free Download Windows 10

Match patterns with regular expressions
Build patterns using metacharacters
Fine-tune patterns with character classes
Check for patterns with preg_match()
Standardize the phone number data
Get rid of the unwanted characters
Matching email addresses can be tricky
Domain suffixes are everywhere
Use PHP to check the domain
Email validation: putting it all together
I got an error and then entered my entire phone number. And then I got a ninja job!
First Name: Jimmy Last Name: Swift Email: [email protected] Phone: (555) 636 4652 Desired Job: Ninja
table of contents
visualizing your data...and more! Drawing dynamic graphics Sure, we all know the power of a good query and a bunch of juicy results. 0003But query results don’t always speak for themselves. Sometimes it’s helpful to cast data in a different light, a more visual light. PHP makes it possible to provide a graphical representation of database data: pie charts, bar charts, Venn diagrams, Rorschach art, you name it. Anything to help users get a grip on the data flowing through your application is game. But not all worthwhile graphics in PHP applications originate in your database. For example, did you know it’s possible to
Add score, add score, add score, add score, add score, add score...
thwart form-filling spam bots with dynamically generated images?
This is ridiculous. I can’t possibly moderate all these posts, most of which appear to be bogus. I don’t even know what a frowney is!
Guitar Wars Reloaded: Rise of the Machines
No input form is safe
We need to separate man from machine
We can defeat automation with automation
Generate the CAPTCHA pass-phrase text
Visualizing the CAPTCHA image
Inside the GD graphics functions
Drawing text with a font
Generate a random CAPTCHA image
Returning sanity to Guitar Wars
Add CAPTCHA to the Add Score script
Five degrees of opposability
Charting mismatchiness
Storing bar graph data
Reading between the lines with the master of charts
From one array to another
Build an array of mismatched topics
Formulating a bar graphing plan
Crunching categories
Doing the category math
Bar graphing basics
Draw and display the bar graph image
Individual bar graph images for all
Mismatch users are digging the bar graphs
table of contents
syndication and web services Interfacing to the world It’s a big world out there, and one that your web application can’t afford to ignore. 0003Perhaps more importantly, you’d rather the world not ignore your web application. One excellent way to tune the world in to your web application is to make its data available for syndication, which means users can subscribe to your site’s content instead of having to visit your web site directly to find new info. Not only that, your application can interface to other applications through web services and take advantage of other people’s data to provide a richer experience.
Some email clients support “push” content, allowing you to receive web site updates the same way you receive email messages.
Many regular web browsers also let you browse “push” content that quickly reveals the latest news posted to a web site.
Even mobile devices provide access to “push” content that is automatically delivered when something on a web site changes.
Owen needs to get the word out about Fang
Push alien abduction data to the people
RSS pushes web content to the people
RSS is really XML
From database to newsreader
Visualizing RSS
What makes a newsman tick
Dynamically generate an RSS feed
Link to the RSS feed
A video is worth a million words
Pulling web content from others
Syndicating YouTube videos
Make a YouTube video request
Owen is ready to build a REST request
YouTube speaks XML
Deconstruct a YouTube XML response
Visualize the XML video data
Access XML data with objects
From XML elements to PHP objects
Drill into XML data with objects
Not without a namespace!
Fang sightings are on the rise
Lay out videos for viewing
Format video data for display
table of contents
leftovers The Top Ten Topics (we didn’t cover) Even after all that, there’s a bit more. 0003 There are just a few more things we think you need to know. We wouldn’t feel right about ignoring them, even though they only need a brief mention. So before you put the book down, take a read through these short but important PHP and MySQL tidbits. Besides, once you’re done here, all that’s left are a couple short appendices... and the index... and maybe some ads... and then you’re really done. We promise! #1. Retrofit this book for PHP4 and mysql functions
#2. User permissions in MySQL
#3. Error reporting for MySQL
#4. Exception handling PHP errors
#5. Object-oriented PHP
#6. Securing your PHP application
#7. Protect your app from cross-site scripting
#8. Operator precedence
#9. What’s the difference between PHP 5 and PHP 6
#10. Reusing other people’s PHP
Dataville Savings & Loan
table of contents
set up a development environment A place to play You need a place to practice your newfound PHP and MySQL skills without making your data vulnerable on the web. 0003 It’s always a good idea to have a safe place to develop your PHP application before unleashing it on the world (wide web). This appendix contains instructions for installing a web server, MySQL, and PHP to give you a safe place to work and practice.
Server computer
Web ser ver Database server
Create a PHP development environment
Find out what you have
Do you have a web server?
Do you have PHP? Which version?
Do you have MySQL? Which version?
Start with the Web Server
PHP installation steps
Installing MySQL
Steps to Install MySQL on Windows
Enabling PHP on Mac OS X
Steps to Install MySQL on Mac OS X
Moving from production to a live site
Dump your data (and your tables)
Prepare to use your dumped data
Move dumped data to the live server
Connect to the live server
table of contents
extend your php Get even more Yes, you can program with PHP and MySQL and create great web applications. 0003 But you know there must be more to it. And there is. This short appendix will show you how to install the mysqli extension and GD graphics library extension. Then we’ll mention a few more extensions to PHP you might want to get. Because sometimes it’s okay to want more. Extending your PHP
And on the Mac...
e You should.dsell and php_gd2 li.dll php_mysq
Grab the version of mysqli to match your version of PHP.
how to use this book
Intro I can’t believe they put that in a PHP & MySQL book.
burning question: “So In this section we answer the PH & MySQL book?” why DID they put that in a P
how to use this book
Who is this book for? If you can answer “yes” to all of these: 1
Are you a web designer with HTML or XHTML experience and a desire to take your web pages to the next level?
Do you want to go beyond simple HTML pages to learn, understand, and remember how to use PHP and MySQL to build web applications?
Do you prefer stimulating dinner party conversation to dry, dull, academic lectures?
this book is for you.
Who should probably back away from this book? If you can answer “yes” to any of these: 1
Are you completely unfamiliar with basic programming concepts like variables and loops? (But even if you’ve never programmed before, you’ll probably be able to get the key concepts you need from this book.)
Are you a kick-butt PHP web developer looking for a reference book?
Are you afraid to try something different? Would you rather have a root canal than mix stripes with plaid? Do you believe that a technical book can’t be serious if it creates an alien abduction database?
this book is not for you.
[Note from marketing: this boo for anyone with a credit card.] k is
xxviii intro
the intro
We know what you’re thinking “How can this be a serious PHP and MySQL book?” “What’s with all the graphics?” “Can I actually learn it this way?”
Your bra THIS is imin thinks portant.
We know what your brain is thinking Your brain craves novelty. It’s always searching, scanning, waiting for something unusual. It was built that way, and it helps you stay alive. So what does your brain do with all the routine, ordinary, normal things you encounter? Everything it can to stop them from interfering with the brain’s real job—recording things that matter. It doesn’t bother saving the boring things; they never make it past the “this is obviously not important” filter. How does your brain know what’s important? Suppose you’re out for a day hike and a tiger jumps in front of you, what happens inside your head and body? Neurons fire. Emotions crank up. Chemicals surge. And that’s how your brain knows... This must be important! Don’t forget it! But imagine you’re at home, or in a library. It’s a safe, warm, tiger‑free zone. You’re studying. Getting ready for an exam. Or trying to learn some tough Your technical topic your boss thinks will take a week, ten days at the most. Just one problem. Your brain’s trying to do you a big favor. It’s trying to make sure that this obviously non-important content doesn’t clutter up scarce resources. Resources that are better spent storing the really big things. Like tigers. Like the danger of fire. Like how to quickly hide the browser window with the YouTube video of space alien footage when your boss shows up.
ks brain thoinrth w THIS isn’t saving.
Great. Only 750 more dull, dry, boring pages.
And there’s no simple way to tell your brain, “Hey brain, thank you very much, but no matter how dull this book is, and how little I’m registering on the emotional Richter scale right now, I really do want you to keep this stuff around.”
UFO footage on YouTube is obviously more interesting to your brain than some computer book.
you are here 4 xxix
how to use this book
t” We think of a “Head Firs
reader as a learner.
ke sure ve to get it, then ma thing? First, you ha me so rn lea the to e on d tak . Base So what does it facts into your head It’s not about pushing onal psychology, ati uc ed d you don’t forget it. urobiology, an ne , ce ien sc e itiv gn ns your brain on. latest research in co . We know what tur ge pa a on t tex n more tha learning takes a lot ciples: First lear ning prin Some of the Head
user_id = 1
much ne, and make learning morable than words alo me re mo far ngs are thi s age studies). It also makes Make it visual. Im in recall and transfer ent vem pro im ate to, rel y 89% the gr aphics the more effective (up to s within or near rd wo e th to t ly Pu like e. as more understandabl rs will be up to twice ther page, and learne ano on or m tto bo rather than on the d to the content. solve problems relate studies, zed style. In recent nal and personali tio sa er nv Error! spoke co a ten e Us g tests if the con t better on post-learnin 40% to up ed ing rm Pass‑phrase unknown. tak n rfo pe tha students versational style rather con , on ers t-p firs a using take directly to the reader, casual language. Don’t instead of lec turing. Use s rie sto l Tel g dinner e. tin ton ula l a forma re attention to: a stim ich would you pay mo Wh . sly iou ser too lf yourse a lec ture? par ty companion, or your less you actively flex ly. In other words, un ep de re mo ious, ink cur th tivated, engaged, Get the learner to A reader has to be mo d. hea r you in t, ns tha pe ch hap knowledge. And for neurons, nothing mu ns, and generate new sio clu con w dra , e ms olv proble activities that inv and inspired to solve vok ing questions, and rcises, and thought-pro exe s, ge llen cha d you nee and multiple senses. both sides of the brain “I really want to learn ion. We’ve all had the nt te at ’s er ad that re he s attention to things Get—and keep—t erience. Your brain pay exp e” on e pag gh, t tou pas , ake Learning a new this but I can’t stay aw -catching, unexpected. eye e, ang str g, stin t. no ere int re quick ly if it’s are out of the ordinary, in will learn much mo e to be boring. Your bra hav ’t esn do ic top l ica techn ely ember something is larg that your ability to rem w kno w en you no wh We r s. be ion about. You remem Touch their emot ember what you care rem You t. king ten tal ’re con al We otion a boy and his dog. dependent on its em renching stories about rt‑w hea g you kin en tal wh t es no ’re “I Rule!” that com feel something. No, we ...?” , and the feeling of the hat “w , t tha fun ity, ing ios eth cur realize you know som emotions like surprise, y else thinks is hard, or od ryb eve ing eth solve a puzzle, learn som ineering doesn’t. n thou” Bob from eng “I’m more technical tha
Small correction. We actually do have a heart-wrenching story about a boy and s, his dog - the dog was abducted by alien and you’ll be helping the boy find him!
xxx intro
the intro
Metacognition: thinking about thinking If you really want to learn, and you want to learn more quickly and more deeply, pay attention to how you pay attention. Think about how you think. Learn how you learn. Most of us did not take courses on metacognition or learning theory when we were growing up. We were expected to learn, but rarely taught to learn.
I wonder how I can trick my brain into remembering this stuff...
But we assume that if you’re holding this book, you really want to learn how to build database-driven web sites with PHP and MySQL. And you probably don’t want to spend a lot of time. If you want to use what you read in this book, you need to remember what you read. And for that, you’ve got to understand it. To get the most from this book, or any book or learning experience, take responsibility for your brain. Your brain on this content. The trick is to get your brain to see the new material you’re learning as Really Important. Crucial to your well‑being. As important as a tiger. Otherwise, you’re in for a constant battle, with your brain doing its best to keep the new content from sticking. So just how DO you get your brain to treat PHP & MySQL like it was a hungry tiger? There’s the slow, tedious way, or the faster, more effective way. The slow way is about sheer repetition. You obviously know that you are able to learn and remember even the dullest of topics if you keep pounding the same thing into your brain. With enough repetition, your brain says, “This doesn’t feel important to him, but he keeps looking at the same thing over and over and over, so I suppose it must be.” The faster way is to do anything that increases brain activity, especially different types of brain activity. The things on the previous page are a big part of the solution, and they’re all things that have been proven to help your brain work in your favor. For example, studies show that putting words within the pictures they describe (as opposed to somewhere else in the page, like a caption or in the body text) causes your brain to try to makes sense of how the words and picture relate, and this causes more neurons to fire. More neurons firing = more chances for your brain to get that this is something worth paying attention to, and possibly recording.
Neuron, schmeuron. Some of us are here to rock!
A conversational style helps because people tend to pay more attention when they perceive that they’re in a conversation, since they’re expected to follow along and hold up their end. The amazing thing is, your brain doesn’t necessarily care that the “conversation” is between you and a book! On the other hand, if the writing style is formal and dry, your brain perceives it the same way you experience being lectured to while sitting in a roomful of passive attendees. No need to stay awake. But pictures and conversational style are just the beginning…
you are here 4 xxxi
how to use this book
Horror movies
Here’s what WE did: We used pictures, because your brain is tuned for visuals, not text. As far as your brain’s concerned, a picture really is worth a thousand words. And when text and pictures work together, we embedded the text in the pictures because your brain works more effectively when the text is within the thing the text refers to, as opposed to in a caption or buried in the text somewhere.
A mismatch!
Horror movies
We used redundancy, saying the same thing in different ways and with different media types, and multiple senses, to increase the chance that the content gets coded into more than one area of your brain. We used concepts and pictures in unexpected ways because your brain is tuned for novelty, and we used pictures and ideas with at least some emotional content, because your brain is tuned to pay attention to the biochemistry of emotions. That which causes you to feel something is more likely to be remembered, even if that feeling is nothing more than a little humor, surprise, or interest. We used a personalized, conversational style, because your brain is tuned to pay more attention when it believes you’re in a conversation than if it thinks you’re passively listening to a presentation. Your brain does this even when you’re reading. We included more than 80 activities, because your brain is tuned to learn and remember more when you do things than when you read about things. And we made the exercises challenging-yet-do-able, because that’s what most people prefer. We used multiple learning styles, because you might prefer step-by-step procedures, while someone else wants to understand the big picture first, and someone else just wants to see an example. But regardless of your own learning preference, everyone benefits from seeing the same content represented in multiple ways. We include content for both sides of your brain, because the more of your brain you engage, the more likely you are to learn and remember, and the longer you can stay focused. Since working one side of the brain often means giving the other side a chance to rest, you can be more productive at learning for a longer period of time. And we included stories and exercises that present more than one point of view, because your brain is tuned to learn more deeply when it’s forced to make evaluations and judgments. We included challenges, with exercises, and by asking questions that don’t always have a straight answer, because your brain is tuned to learn and remember when it has to work at something. Think about it—you can’t get your body in shape just by watching people at the gym. But we did our best to make sure that when you’re working hard, it’s on the right things. That you’re not spending one extra dendrite processing a hard-to-understand example, or parsing difficult, jargon-laden, or overly terse text. We used people. In stories, examples, pictures, etc., because, well, because you’re a person. And your brain pays more attention to people than it does to things.
xxxii intro
Try this!
Test Drive
the intro
Here’s what YOU can do to bend your brain into submission So, we did our part. The rest is up to you. These tips are a starting point; listen to your brain and figure out what works for you and what doesn’t. Try new things.
Cut this out and sti on your it 1
Slow down. The more you understand, the less you have to memorize.
Speaking activates a different part of the brain. If you’re trying to understand something, or increase your chance of remembering it later, say it out loud. Better still, try to explain it out loud to someone else. You’ll learn more quickly, and you might uncover ideas you hadn’t known were there when you were reading about it.
Don’t just read. Stop and think. When the book asks you a question, don’t just skip to the answer. Imagine that someone really is asking the question. The more deeply you force your brain to think, the better chance you have of learning and remembering. 2
Do the exercises. Write your own notes.
Read the “There are No Dumb Questions”
Make this the last thing you read before bed. Or at least the last challenging thing.
Part of the learning (especially the transfer to long-term memory) happens after you put the book down. Your brain needs time on its own, to do more processing. If you put in something new during that processing time, some of what you just learned will be lost. 5
Drink water. Lots of it.
Your brain works best in a nice bath of fluid. Dehydration (which can happen before you ever feel thirsty) decreases cognitive function.
Feel something.
Your brain needs to know that this matters. Get involved with the stories. Make up your own captions for the photos. Groaning over a bad joke is still better than feeling nothing at all.
That means all of them. They’re not optional sidebars—they’re part of the core content! Don’t skip them. 4
Listen to your brain.
Pay attention to whether your brain is getting overloaded. If you find yourself starting to skim the surface or forget what you just read, it’s time for a break. Once you go past a certain point, you won’t learn faster by trying to shove more in, and you might even hurt the process.
We put them in, but if we did them for you, that would be like having someone else do your workouts for you. And don’t just look at the exercises. Use a pencil. There’s plenty of evidence that physical activity while learning can increase the learning. 3
Talk about it. Out loud.
Write a lot of code!
There’s only one way to learn to program: writing a lot of code. And that’s what you’re going to do throughout this book. Coding is a skill, and the only way to get good at it is to practice. We’re going to give you a lot of practice: every chapter has exercises that pose problems for you to solve. Don’t just skip over them—a lot of the learning happens when you solve the exercises. We included a solution to each exercise—don’t be afraid to peek at the solution if you get stuck! (It’s easy to get snagged on something small.) But try to solve the problem before you look at the solution. And definitely get it working before you move on to the next part of the book.
PHP and MySQL let you build real-world web applications - don’t forget to upload them and try them out on a real web server.
you are here 4 xxxiii
how to use this book
Read Me This is a learning experience, not a reference book. We deliberately stripped out everything that might get in the way of learning whatever it is we’re working on at that point in the book. And the first time through, you need to begin at the beginning, because the book makes assumptions about what you’ve already seen and learned. We begin by teaching simple programming concepts and database connection basics, then more complicated PHP functions and MySQL statements, and finally more complex application concepts. While it’s important to create applications that allow users to add data to and retrieve data from your web application, before you can do that you need to understand the syntax of both PHP and MySQL. So we begin by giving you PHP and MySQL statements that you can actually try yourself. That way you can immediately do something with PHP and MySQL, and you will begin to get excited about them. Then, a bit later in the book, we show you good application and database design practices. By then you’ll have a solid grasp of the syntax you need, and can focus on learning the concepts. We don’t cover every PHP and MySQL statement, function, or keyword. While we could have put every single PHP and MySQL statement, function, and keyword in this book, we thought you’d prefer to have a reasonably liftable book that would teach you the most important statements, functions, and keywords. We give you the ones you need to know, the ones you’ll use 95 percent of the time. And when you’re done with this book, you’ll have the confidence to go look up that function you need to finish off that You kick‑ass application you just wrote. We support PHP 5 and MySQL 5.0.
can actually use PHP 4 with this book by making a few modifications to the code. Check them out in #1 of Appendix i.
Because so many people still use PHP 4 or 5, we avoid any PHP 4, 5, or 6 specific code wherever possible. We suggest you use PHP 5 or 6 and MySQL 5 or 6 while learning the concepts in this book. In developing this book, we focused on PHP 5 and MySQL 5, while making sure our code was compatible with later versions. You need a web server that supports PHP.
PHP has to be run through a web server to work correctly. You need Apache or some other web server installed on your local machine or a machine to which you have some access so that you can run MySQL commands on the data. Check out Appendixes ii and iii for instructions on how to install and extend PHP and MySQL.
xxxiv intro
the intro
We use MySQL. While there’s Standard SQL language, in this book we focus on the particular syntax of MySQL. With only a few syntax changes, the code in this book should work with Oracle, MS SQL Server, PostgreSQL, DB2, and quite a few more Relational Database Management Systems (RDBMSs) out there. You’ll need to look up the particular PHP functions and syntax if you want to connect to these other RDBMSs. If we covered every variation in syntax for every command in the book, this book would have many more pages. We like trees, so we’re focusing on MySQL. The activities are NOT optional. The exercises and activities are not add-ons; they’re part of the core content of the book. Some of them are to help with memory, some are for understanding, and some will help you apply what you’ve learned. Don’t skip the exercises. The crossword puzzles are the only thing you don’t have to do, but they’re good for giving your brain a chance to think about the words and terms you’ve been learning in a different context. The redundancy is intentional and important. One distinct difference in a Head First book is that we want you to really get it. And we want you to finish the book remembering what you’ve learned. Most reference books don’t have retention and recall as a goal, but this book is about learning, so you’ll see some of the same concepts come up more than once. The examples are as lean as possible. Our readers tell us that it’s frustrating to wade through 200 lines of an example looking for the two lines they need to understand. Most examples in this book are shown within the smallest possible context, so that the part you’re trying to learn is clear and simple. Don’t expect all of the examples to be ultra robust, or always complete—they are written specifically for learning, and aren’t necessarily fully-functional. We’ve placed all of the example code and applications on the Web so you can copy and paste parts of them into your text editor or MySQL Terminal, or upload them as-is to your own web server for testing. You’ll find it all at
Several of the examples are full-blown web applications that do some pretty powerful things.
The Brain Power exercises don’t have answers. For some of them, there is no right answer, and for others, part of the learning experience of the Brain Power activities is for you to decide if and when your answers are right. In some of the Brain Power exercises, you will find hints to point you in the right direction.
you are here 4 xxxv
the review team
The technical review team Jereme Allen
David Briggs
Will Harris
Technical Reviewers: Jereme Allen is a senior level web developer with experience utilizing state of the art technologies to create web applications. He has nine plus years of experience utilizing PHP, MySQL, as well as various other frameworks, operating systems, programming languages and development software. David Briggs is a technical author and software localization engineer living in Birmingham, England. When he’s not being finicky about how to guide users through a particularly tricky piece of software, he likes nothing better than to get out in the local park with his wife, Paulette, and Cleo, the family dog. Will Harris spends his days running an IT department that provides services to 11 companies on 4 continents, and he is the Vice President of the Las Vegas PASS (Professional Association for SQL Server) chapter. At night, he hops into a phone booth and puts on his web 2.0 suit, helping the designers and developers at Powered By Geek ensure that their data platforms are flexible, portable, maintainable, and FAST, using MySQL and Rails. He also enjoys spending time with his wife, Heather, his beautiful children, Mara and Ellie, and his dog, Swiper. Stephanie Liese is a technical trainer and web developer in Sacramento, California. When she isn’t extolling the virtues of standards compliant code or debugging a CSS layout, you will find her sweating it out in a hot yoga class. xxxvi intro
Stephanie Liese
Harvey Quamen
Steve Milano
Chris Shiflett
If Steve Milano isn’t slinging code for The Day Job™ or playing punk rock with his band, Onion Flavored Rings, in some unventilated basement, he’s probably at home with his laptop, neglecting feline companion, Ralph, and human companion, Bianca. Harvey Quamen gave up a computer programming career to join the jet-setting, paparazzi-filled, high profile world of academia. He’s currently an Associate Professor of English and Humanities Computing at the University of Alberta, where he teaches courses on cyberculture, 20th-century literature, and web development—including PHP and MySQL. Chris Shiflett is the Chief Technology Officer of OmniTI, where he leads the web application security practice and guides web development initiatives. Chris is a thought leader in the PHP and web application security communities—a widely-read blogger at, a popular speaker at industry conferences worldwide, and the founder of the PHP Security Consortium. His books include Essential PHP Security (O’Reilly) and HTTP Developer’s Handbook (Sams).
the intro
Acknowledgments Our editors: Many thanks go to Brett McLaughlin for the awesome storyboarding session that got us on the right track, and his ruthless commitment to cognitive learning. The book would not exist if not for the heroic effort, patience, and persistence of Sanders Kleinfeld. He always managed to catch the balls, or was it cats, we were juggling when we inevitably dropped one (or three!), and we appreciate it. We hope he gets a chance to put his feet up for a couple of days before taking on another project as difficult as this one.
Brett McLaughlin
The O’Reilly team: Thanks to Lou Barr for her phenomenal design skill, making this book such a visual treat. Thanks also to Brittany Smith for all her hard work at the last minute, and to Caitrin McCullough for getting the example web sites up and running. And to Laurie Petrycki for having faith that we could write another great Head First book.
Sanders Kleinfeld
Lou Barr And more: Finally, a big thanks goes out to Elvis Wilson for putting together the alien YouTube videos for Chapter 12. Excellent job! Especially seeing as how he’s merely a simple caveman art director.
you are here 4 xxxvii
safari books online
Safari® Books Online When you see a Safari® icon on the cover of your favorite technology book that means the book is available online through the O’Reilly Network Safari Bookshelf. Safari offers a solution that’s better than e-books. It’s a virtual library that lets you easily search thousands of top tech books, cut and paste code samples, download chapters, and find quick answers when you need the most accurate, current information. Try it for free at
xxxviii intro
1 add life to your static pages
It’s Alive Just let her tell me I’m boring now...
You’ve been creating great web pages with HTML, and a sprinkling of CSS.0003 But you’ve noticed that visitors to your site can’t do much other than passively look at the content on the pages. The communication’s one-way, and you’d like to change that. In fact, you’d really like to know what your audience is thinking. But you need to be able to allow users to enter information into a web form so that you can find out what’s on their minds. And you need to be able to process the information and have it delivered to you. It sounds as if you’re going to need more than HTML to take your site to the next level.
this is a new chapter 0018
sometimes just HTML isn’t enough
HTML is static and boring HTML’s great for creating web pages, that much we already know. But what about when you need web pages that actually do something? Suppose you need to search a database or send an email... what then? HTML falls short because it’s a pretty lifeless language, designed for displaying information that never changes.
HTML is great if you just want to share a picture of your pet... but not so great if you want to interact with visitors to your site.
The HTML code in these pages is determined when the web developer creates the pages.
Web server
only changed Static HTML pages arede its a .html file when a web developer web server. and uploads it to their
Client web browser
The web server’s a big part of the problem with lifeless HTML since it serves as nothing more than a boring delivery mechanism. A browser requests a page, the server responds with HTML, end of story. To turn web sites into interactive web applications, the web server has to take on a new, more dynamic role... a role made possible by PHP.
0018 Chapter 1
These people are looking for interaction!
The web server is limited to serving up one static HTML page after another.
With pure HTML web pages, the server simply serves up static HTML that can only display content.
PHP brings web pages to life
With a little help from the server!
PHP allows you to manipulate web page content on the server just before a page is delivered to the client browser. It works like this: A PHP script runs on the server and can alter or generate HTML code at will. An HTML web page is still delivered to the browser, which doesn’t know or care that PHP is involved in tweaking the HTML on the server.
The browser still receives regular HTML web pages, but the code’s been dynamically generated by PHP on the server.
The HTML code in these pages is generated by PHP and can change dynamically depending on what the web application needs.
add life to your static pages
With PHP in the mix, the web server is able to dynamically generate HTML web pages on the fly. PHP scripts are stored on the web server, wher they’re processed and e then delivered to the browser as HTML pages. Web server
Client web browser
PHP PHP scripts contain both HTML code and PHP scriptthe code that determines how HTML code’s manipulated.
Dynamic HTML pages change in response to programmatic logic in PHP scripts, making them incredibly flexible. MySQL Database
PHP stores and retrieves data from a database and incorporates the data into the HTML code that it generates. you are here 4 0018
sending out an (internet) sos
Dogs in space Meet Owen. Owen’s lost his dog, Fang. But finding his dog isn’t just a matter of searching the neighborhood. You see, Fang was abducted by aliens, which expands Owen’s search to the entire galaxy. Owen knows some HTML and CSS, and he thinks a custom web site may help solve his problem by allowing other people to share their own alien abduction experiences. But to get information from others, Owen’s going to need a web form that’s capable of receiving user input, lots of it, and notifying him about it. Not a problem—HTML has plenty of tags for whipping together web forms.
Have you seen him?
do Details are sketchy, butiskweed wh s wa know that Fang ht. into the sky in a beam of lig
Owen knows some HTML and CSS and thinks he might be able to use the web to help track down his dog, Fang.
0018 Chapter 1
add life to your static pages
A form helps Owen get the whole story Owen’s new web site,, aims to connect Owen with alien abductees who might be able to shed some light on Fang’s disappearance. Owen knows he needs an HTML form to solicit abduction stories from visitors and that it must find out if they’ve run into Fang during their interstellar journeys. But he needs your help getting it up and running. Here’s what he has in mind for the form.
Here’s the field for the visitor’s email address. Owen wants a physical description of the aliens.
Owen hopes someone will answer yes, that they saw Fang on the alien spacecraft.
Any additional comments can go here. Owen wants to receive an email message when the user submits the form.
This form is pure 100% Grade A HTML!
What do you think of Owen’s HTML form? Can you think of any problems Owen might face when he tries to gather alien abduction data using this form? Go ahead, jot down your thoughts.
you are here 4 0018
owen’s form html
Forms are made of HTML Owen’s Report an Abduction form is built entirely out of HTML tags and attributes. There are text fields for most of the questions, radio buttons to find out if his visitor saw Fang, and a text area for additional comments. And the form is set up to deliver form data to Owen’s email address.
If you need a refresher on creating HTML forms, check out Chapter 14 of Head First HTML with CSS & XHTML.Focused.
Owen will get the contents of this form sent to him at this email address - change Owen’s email address to yours to test out the form.
“mailto” is a protocol that allows form data to be delivered via email.

Share your story of alien abduction:

The form is bracketed with open and close
0018 Chapter 1
No surprises here - the form is pure, 100% HTML code!
The submit button tells the form to execute the form action.
add life to your static pages
Test Drive Try out the Report an Abduction form. Download the code for the Report an Abduction web page from the Head First Labs web site at It’s in the chapter01 folder. The folder contains Owen’s web form in report.html, as well as a style sheet (style.css) and an image of Fang (fang.jpg). Open the report.html page in a text editor and change Owen’s email address to yours. Then open the page in a web browser, enter some alien abduction information in the form, and click the Report Abduction button.
Submitting the form results in the form data getting emailed...sort of.
l report.htm
The HTML form doesn’t know how to actually send an email message, so it delegates the task to the user’s own email program.
The form data isn't sent to Owen unless the user manually sends the weird looking email. So, what do you think? Did you receive the form data as an email message in your Inbox?
you are here 4 0018
mailto = bad idea
The HTML form has problems Owen’s Report an Abduction form is up and running, but he doesn’t get much information from users. Is Fang’s abduction really such an isolated incident... or is something wrong with his form? Let’s see what the users have to say about it. When I click the button, it opens my email program, Outlook, and doesn’t have anything I just spent 15 minutes typing in the form! I saw something like this in the Subject field: ?When=&Where=. I’m confused.
I had a blank email to fill out. All my carefully typed answers from the form were ignored. Someone should abduct this stupid form!
Nothing happened because my web browser has no default email client... whatever that is.
Somehow Owen’s form is ext tin g more frustration than informrac ati on from visitors to his site.
What’s going on here? Do you have any ideas about how to fix the form?
0018 Chapter 1
add life to your static pages
The form looks OK. Does the problem have something to do with that mailto part?
Yes. The HTML form code is fine, but mailto isn’t a good way to deliver form data. Owen’s form is perfectly fine until the user clicks the Report Abduction button. At that point you rely on mailto to package up the form data in an email. But this email doesn’t get sent automatically—it’s created in the default email program on the user’s computer instead. And the real kicker... the user has to send the email themselves in order for the data to get sent to you! So you have no control over the email delivery, meaning that it may or may not successfully make the trip from your web form through their browser to their email client and back to you as an email message. Not good. You need a way to take control of the delivery of the web form. More specifically, you need PHP to package the form data into an email message, and then make sure it gets sent. This involves shifting your attention from the client (HTML, mailto, etc.) to the server (PHP).
The form’s wonderful until you click Report Abduction - then all bets are off!
you are here 4 0018
client-side versus server-side
HTML acts on the CLIENT Owen’s form is written in pure HTML with a mailto form action that attempts to send the form data via email. Although the report.html web page comes from a web server, it’s filled out and processed entirely on the user’s web browser.
I’d like Owen’s Report an Abduction web page, please.
Your computer’s browser software runs here, also known as a CLIENT.
Now, I’d like to submit Owen’s form with the data the user entered, please
Owen may or may not get the email.
Here you go.
1 The browser requests Owen’s web page, which includes the form.
2 The server returns the HTML code for the web page.
3 The user fills out the form and submits it.
Um, I don’t get involved here.
5 The server sends an HTML confirmation to the browser.
Check the boxes for where you think a PHP script belongs: Client
I process the form information and send the email myself.
4 The PHP script generates an HTML confirmation page and emails the form data to Owen.
Owen is guaranteed to get a nicely formatted email.
you are here 4 11
php is a server-side language
PHP scripts run on the server PHP code runs on the server and is stored in PHP scripts that usually have a .php file extension. PHP scripts often look a lot like normal HTML web pages because they can contain both HTML code and CSS code. In fact, when the server runs a PHP script the end result is always pure HTML and CSS. So every PHP script ultimately gets turned into HTML and CSS once it’s finished running on the server. Let’s take a closer look at how a PHP script changes the flow of Owen’s web form.
1 The client web browser requests an HTML web page, in this case, the Report an Abduction form.
2 The server returns the HTML web page.
Clicking Report Abduction submits the form data to the PHP script on the server. 3 The user fills out the form and submits it, causing the browser to pass along the form data to a PHP script on the server.
12 Chapter 1
add life to your static pages
PHP is a server-side programming language - it runs on a web server. 5 The server returns a pure HTML web page that was generated by the PHP script.
Although the page name shows with a .php name in the browseup it’s pure HTML at this point. r,
The PHP script runs on the server! report.php
6 The browser displays the confirmation web page.
The user sees a confirmation web page.
4 The server runs the PHP script, which sends an email and generates an HTML confirmation web page.

Get Organized. Get Focused. Get Moving. PDF Free Download Books

7 The email is delivered to Owen’s Inbox.
Owen receives the email.
you are here 4 13
the form action attribute
Okay. But what actually causes a PHP script to get run on the server?
A form element’s action attribute is what connects a form to a PHP script, causing the script to run when the form is submitted. Forms are created using the HTML tag, and every tag has an action attribute. Whatever filename you set the action attribute to is used by the web server to process the form when it is submitted. So if Owen’s PHP script is named report.php, then the tag that connects it to the form looks like this:
This is the filename of your PHP script.
When the user clicks the Report Abduction button in the form, the form action causes the report.php script to be run on the server to process the form data.
Aliens Abducted Me - Report an Abduction</titl e></head><body><h2>Aliens Abducted Me - Repor t an Abduction</h2><link type= 'text/css' href='style.css ' /></head><body><h2>Aliens Abducted Me - Repor t an Abduction</h2><br><br>report.html<br><br><p>Share your story of alien abduction:</p><form method='post' action='re port.php'><label for='firstname'>Firs t name:</label><input type='text' name='firstname'<br><br>The action attribute of the <form> tag is what causes the PHP script to run on the server when the form is submitted.<br><br>/><br><br><br>report.php<br><br>14 Chapter 1<br><br> add life to your static pages<br><br>Q: A:<br><br>What does PHP stand for?<br><br>PHP is an acronym that originally stood for Personal Home Pages. Somewhere along the way the acronym was changed to mean PHP: Hypertext Processor. The latter is considered a recursive acronym because it references itself—the acronym (PHP) is inside the acronym. Clever? Confusing? You decide!<br><br>Q:<br><br>Even though my web browser shows that a web page has a name that ends in .php, it’s still pure HTML? How is that?<br><br>A:<br><br>It’s possible because the page originates as PHP code on the server but is transformed into HTML code before making its way to the browser. So the server runs the PHP code and converts it into HTML code before sending it along to the browser for viewing. This means that even though a .php file contains PHP code, the browser never sees it—it only sees the HTML code that results from running the PHP code on the server.<br><br>Q:<br><br>But don’t all web pages originate on the server, even pure HTML pages in .html files?<br><br>A:<br><br>Yes. All of the files for a web site are stored on the server—.html, .css, .php, etc. But they aren’t all processed by the server. HTML and CSS files, as well as image files, are sent directly to the client browser without worrying about what’s actually inside them. PHP files are different because they contain code that’s processed and run on the web server. It’s not the PHP code that’s sent to the browser, it’s the results of running the PHP code that are sent, and these results are pure HTML and CSS.<br><br>you are here 4 15<br><br> your first php script<br><br>Use PHP to access the form data So Owen needs a PHP script that can get the alien abduction form information to him more reliably than the mailto technique. Let’s create it. Don’t worry about understanding everything yet—we’ll get to that:<br><br>PHP scripts often start out looking a lot like HTML web pages.<br><br><html><br><br>It’s perfectly normal for a PHP script to include regular HTML tags and attributes.<br><br><head><title>Aliens Abducted Me - Report an Abduction

Aliens Abducted Me - Report an Abduction

Ah, here’s where things get interesting - this is the beginning of the actual PHP code.
This entire block of script code is PHP...the rest of the script is normal HTML.
This chunk of PHP code grabs the form data so that it can be displayed as part of a confirmation page.
echo 'Thanks for submitting the form.
'; echo 'You were abducted ' . $when_it_happened; echo ' and were gone for ' . $how_long . '
'; echo 'Describe them: ' . $alien_description . '
'; echo 'Was Fang there? ' . $fang_spotted . '
'; echo 'Your email address is ' . $email; ?>