Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Buy Now $35.99
Standard view
Full view
of .
Look up keyword or section
Like this
39Activity

Table Of Contents

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
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 PHP
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
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
–POST provides the form data
Owen needs help sifting through his data
Owen’s on his way to finding Fang
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
Use WHERE to DELETE specific data
Minimize the risk of accidental deletions
MakeMeElvis.com is a web application
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
Virtual guitarists like to compete
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?
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"
Timing is everything with high scores
Honoring the top Guitar Warrior
Format the top score with HTML and CSS
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
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 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!
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()
Authorizing users with HTTP
Logging In Users with HTTP Authentication
A form for signing up new users
What’s in a cookie?
Bakecookies 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
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
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
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
The complete Search script, continued
Risky Jobs lets users submit resumes
Decide what your data should look like
Formulate a pattern for phone numbers
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
Email validation: putting it all together
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
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
What makes a newsman tick
Dynamically generate an RSS feed
Link to the RSS feed
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
Format video data for display
P. 1
Head First PHP & MySQL

Head First PHP & MySQL

Ratings:

4.05

(19)
|Views: 7,012 |Likes:

If you're ready to create web pages more complex than those you can build with HTML and CSS, Head First PHP & MySQL is the ultimate learning guide to building dynamic, database-driven websites using PHP and MySQL. Packed with real-world examples, this book teaches you all the essentials of server-side programming, from the fundamentals of PHP and MySQL coding to advanced topics such as form validation, session IDs, cookies, database queries and joins, file I/O operations, content management, and more.

Head First PHP & MySQL offers the same visually rich format that's turned every title in the Head First series into a bestseller, with plenty of exercises, quizzes, puzzles, and other interactive features to help you retain what you've learned.

Use PHP to transform static HTML pages into dynamic web sites Create and populate your own MySQL database tables, and work with data stored in files Perform sophisticated MySQL queries with joins, and refine your results with LIMIT and ORDER BY Use cookies and sessions to track visitors' login information and personalize the site for users Protect your data from SQL injection attacks Use regular expressions to validate information on forms Dynamically display text based on session info and create images on the fly Pull syndicated data from other sites using PHP and XML Throughout the book, you'll build sophisticated examples -- including a mailing list, a job board, and an online dating site -- to help you learn how to harness the power of PHP and MySQL in a variety of contexts. If you're ready to build a truly dynamic website, Head First PHP & MySQL is the ideal way to get going.

If you're ready to create web pages more complex than those you can build with HTML and CSS, Head First PHP & MySQL is the ultimate learning guide to building dynamic, database-driven websites using PHP and MySQL. Packed with real-world examples, this book teaches you all the essentials of server-side programming, from the fundamentals of PHP and MySQL coding to advanced topics such as form validation, session IDs, cookies, database queries and joins, file I/O operations, content management, and more.

Head First PHP & MySQL offers the same visually rich format that's turned every title in the Head First series into a bestseller, with plenty of exercises, quizzes, puzzles, and other interactive features to help you retain what you've learned.

Use PHP to transform static HTML pages into dynamic web sites Create and populate your own MySQL database tables, and work with data stored in files Perform sophisticated MySQL queries with joins, and refine your results with LIMIT and ORDER BY Use cookies and sessions to track visitors' login information and personalize the site for users Protect your data from SQL injection attacks Use regular expressions to validate information on forms Dynamically display text based on session info and create images on the fly Pull syndicated data from other sites using PHP and XML Throughout the book, you'll build sophisticated examples -- including a mailing list, a job board, and an online dating site -- to help you learn how to harness the power of PHP and MySQL in a variety of contexts. If you're ready to build a truly dynamic website, Head First PHP & MySQL is the ideal way to get going.

More info:

Publish date: Nov 15, 2008
Added to Scribd: May 16, 2009
Copyright:Traditional Copyright: All rights reservedISBN:9780596800802
List Price: $35.99 Buy Now

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
This book can be read on up to 6 mobile devices.
Buy the full version from:Amazon
See more
See less

12/11/2014

814

9780596800802

$35.99

USD

You're Reading a Free Preview
Pages 33 to 197 are not shown in this preview.
You're Reading a Free Preview
Pages 230 to 551 are not shown in this preview.
You're Reading a Free Preview
Pages 599 to 738 are not shown in this preview.
You're Reading a Free Preview
Pages 771 to 814 are not shown in this preview.

Activity (39)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
1 hundred thousand reads
kaosad liked this
Iva Yui liked this
Angel Becerra liked this
nava2013 liked this
Chan Kok Peng liked this
pdesign1 liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->