Contents
Contents
Robin Nixon
Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii
v
Logging In 29
Using FTP 29
Using a Program Editor 30
Using an IDE 31
Questions 33
3. Introduction to PHP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Incorporating PHP Within HTML 35
This Book’s Examples 37
The Structure of PHP 38
Using Comments 38
Basic Syntax 39
Variables 40
Operators 45
Variable Assignment 48
Multiple-Line Commands 50
Variable Typing 52
Constants 53
Predefined Constants 54
The Difference Between the echo and print Commands 55
Functions 55
Variable Scope 56
Questions 62
vi | Table of Contents
Breaking Out of a Loop 88
The continue Statement 89
Implicit and Explicit Casting 90
PHP Dynamic Linking 91
Dynamic Linking in Action 92
Questions 93
Table of Contents | ix
Creating a Login File 236
Connecting to a MySQL Database 237
A Practical Example 243
The $_POST Array 246
Deleting a Record 247
Displaying the Form 247
Querying the Database 248
Running the Program 249
Practical MySQL 250
Creating a Table 251
Describing a Table 251
Dropping a Table 252
Adding Data 253
Retrieving Data 254
Updating Data 255
Deleting Data 255
Using AUTO_INCREMENT 256
Performing Additional Queries 257
Preventing Hacking Attempts 258
Steps You Can Take 259
Using Placeholders 260
Preventing HTML Injection 263
Using mysqli Procedurally 264
Questions 266
x | Table of Contents
The list Attribute 285
The color Input Type 285
The number and range Input Types 285
Date and Time Pickers 286
Questions 286
Table of Contents | xi
Functions 321
Global Variables 321
Local Variables 321
The Document Object Model 322
Another Use for the $ Symbol 324
Using the DOM 325
About document.write 326
Using console.log 326
Using alert 326
Writing into Elements 326
Using document.write 327
Questions 327
Table of Contents | xv
Transformations 474
3D Transformations 475
Transitions 476
Properties to Transition 476
Transition Duration 477
Transition Delay 477
Transition Timing 477
Shorthand Syntax 478
Questions 480
xx | Table of Contents
login.php 689
profile.php 691
Adding the “About Me” Text 692
Adding a Profile Image 692
Processing the Image 692
Displaying the Current Profile 693
members.php 696
Viewing a User’s Profile 696
Adding and Dropping Friends 697
Listing All Members 697
friends.php 700
messages.php 703
logout.php 706
styles.css 708
javascript.js 710
Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 777