Nixon, Robín
Php, mysql, javascript, & css
Nixon, Robín
- 560 páginas, ilustraciones 23 x 18 cm
Preface... Table of Contents 1. Introduction to Dynamic Web Content HTTP and HTML: Berners-Lee's Basics The Request/Response Procedure The Benefits of PHP, MySQL, JavaScript, and CSS Using PHP Using MySQL Using JavaScript Using CSS The Apache Web Server About Open Source Bringing It All Together Test Your Knowledge 2. Setting Up a Development Server What Is a WAMP, MAMP, or LAMP? Installing a WAMP on Windows Testing the Installation Alternative WAMPS Installing a MAMP on Mac OS X Configuring MySQL Testing the Installation Installing a LAMP on Linux Working Remotely Logging In Using FTP Using a Program Editor Using an IDE Questions xvii 2 2 5 6 7 9 9 10 10 12 13 14 14 26 29 29 31 33 34 35 35 35 37 3 3 084-10427 3. Introduction to PHP Incorporating PHP Within HTML Calling the PHP Parser This Book's Examples The Structure of PHP Using Comments Basic Syntax Understanding Variables Operators Variable Assignment Multiple-Line Commands Variable Typing Constants The Difference Between the echo and print Commands Functions Variable Scope 41 41 42 43 44 44 45 46 50 53 55 58 58 Test Your Knowledge 4. Expressions and Control Flow in PHP. Expressions Literals and Variables Operators Operator Precedence Associativity Relational Operators Conditionals The if Statement The else Statement The elseif Statement The switch Statement The? Operator 60 60 61 66 69 69 70 71 72 74 75 79 79 80 82 82 85 86 87 89 89 Looping while Loops do...while Loops for Loops Breaking Out of a Loop The continue Statement Implicit and Explicit Casting Dynamic Linking in Action PHP Dynamic Linking Test Your Knowledge 91 92 93 94 94 95 vi | Table of Contents 5. PHP Functions and Objects PHP Functions Defining a Function Returning a Value Returning an Array Passing by Reference Returning Global Variables Recap of Variable Scope Including and Requiring Files The include Statement Using include_once Using require and require_once 97 98 100 101 102 103 104 104 PHP Version Compatibility PHP Objects Terminology Declaring a Class Creating an Object Accessing Objects Constructors Writing Methods Declaring Properties Declaring Constants Property and Method Scope in PHP 5 Inheritance Test Your Knowledge 6. PHP Arrays.... Basic Access Numerically Indexed Arrays Associative Arrays Assignment Using the array Keyword Multidimensional Arrays The foreach...as Loop Using Array Functions is_array count sort shuffle explode extract compact reset end 104 105 105 106 106 107 108 109 109 112 113 114 115 116 118 121 ..123 123 123 125 126 126 128 131 131 131 132 132 132 133 134 135 135 Table of Contents vii Test Your Knowledge 7. Practical PHP Using printf Precision Setting String Padding Using sprintf Date and Time Functions 736 137 137 138 140 141 141 144 144 Date Constants 145 Using checkdate File Handling Checking Whether a File Exists 145 145 147 Creating a File 147 Reading from Files 148 Copying Files 148 Moving a File 149 Deleting a File 150 Updating Files Uploading Files Reading an Entire File Locking Files for Multiple Accesses 151 152 157 158 System Calls 159 XHTML 159 The Benefits of XHTML 159 XHTML. Versions 160 What's Different? Test Your Knowledge 8. Introduction to MySQL... MySQL Basics HTML 4.01 Document Types The HTML5 Document Type XHTML 1.0 Document Types XHTML Validation 161 161 162 163 ... 165 165 MySQL Commands Summary of Database Terms Accessing MySQL via the Command Line Starting the Command-Line Interface Using the Command-Line Interface Data Types Indexes Creating an Index Querying a MySQL Database 166 166 167 170 172 176 185 186 191 Cable of Contents ECNI Joining Tables Together Using Logical Operators MySQL Functions Windows Users OS X Users Linux Users Using phpMyAdmin Test Your Knowledge Accessing MySQL. via phpMyAdmin 200 202 203 203 203 205 205 205 9. Mastering MySQL Database Design 206 Transactions Transaction Storage Engines Using BEGIN Using COMMIT Normalization First Normal Form Second Normal Form Third Normal Form When Not to Use Normalization Relationships One-to-One One-to-Many Many-to-Many Databases and Anonymity Primary Keys: The Keys to Relational Databases 209 209 210 211 212 214 216 218 219 219 220 220 222 222 223 224 224 Using ROLLBACK Using EXPLAIN Backing Up and Restoring Using mysqldump 225 225 227 227 Creating a Backup File Restoring from a Backup File Dumping Data in CSV Format 228 230 230 Planning Your Backups 231 Test Your Knowledge 10. Accessing MySQL Using PHP Querying a MySQL Database with PHP The Process Creating a Login File Connecting to MySQL A Practical Example 231 .... 233 233 233 234 235 240 Je 2155 Table of Contents is 242 243 11. Form Handling Building Forms Retrieving Submitted Data The S. POST Array Deleting a Record Displaying the Form Querying the Database Running the Program Practical MySQL Creating a Table Describing a Table Dropping a Table Adding Data Retrieving Data Updating Data Deleting Data Using AUTO_INCREMENT Performing Additional Queries Preventing SQL Injection Preventing HTML Injection Test Your Knowledge 243 244 245 246 246 247 248 248 249 230 230 251 252 253 256 258 259 259 260 262 Setting a Cookie Using Cookies in PHP register_globals: An Old Solution Hangs On Default Values Input Types Sanitizing Input An Example Program Test Your Knowledge 12. Cookies, Sessions, and Authentication.. 262 263 270 271 274 ...275 275 277 277 278 Accessing a Cookie 278 HTTP Authentication Destroying a Cookie 281 Storing Usernames and Passwords 281 285 Salting 285 Using Sessions Ending a Session Starting a Session 288 290 293 Session Security Test Your Knowledge Table of Contents 13. Exploring JavaScript JavaScript and HTML Text Using Scripts Within a Document Head Older and Nonstandard Browsers Including JavaScript Files Debugging JavaScript Errors Using Comments Semicolons Variables String Variables Numeric Variables Arrays Operators Arithmetic Operators Assignment Operators Comparison Operators Logical Operators Variable Incrementing and Decrementing String Concatenation Escaping Characters Variable Typing Functions Global Variables Local Variables The Document Object Model (DOM) But It's Not That Simple Using the DOM Test Your Knowledge 14. Expressions and Control Flow in JavaScript.. Expressions Literals and Variables Operators Operator Precedence Associativity Relational Operators The with Statement Using onerror Using try...catch Conditionals The if Statement The switch statement The? Operator 295 295 297 297 298 299 301 301 302 302 302 303 303 304 304 305 305 305 306 306 307 307 308 308 309 311 312 313 315 315 316 317 318 318 319 322 322 323 324 324 325 327 Table of Contents xi Numeric Arrays Associative Arrays Character Classes Regular Expressions Matching Through Metacharacters Fuzzy Character Matching Grouping Through Parentheses Multidimensional Arrays Using Array Methods Test Your Knowledge 16. JavaScript and PHP Validation and Error Handling. Validating User Input with JavaScript The validate.html Document (Part One) Looping while Loops do... while Loops for Loops Breaking Out of a Loop The continue Statement Explicit Casting Test Your Knowledge 15. JavaScript Functions, Objects, and Arrays. JavaScript Functions Defining a Function Returning a Value Returning an Array JavaScript Objects Declaring a Class Creating an Object Accessing Objects The prototype Keyword JavaScript Arrays 331 333 927 726 17 324 324 130 331 333 333 337 337 337 337 339 339 340 342 342 343 344 345 349 351 351 352 354 The validate.html Document (Part Two) 357 357 358 359 359 360 General Modifiers Summary of Metacharacters Some More Complicated Examples 363 364 365 Using Regular Expressions in PHP Using Regular Expressions in JavaScript 365 366 Redisplaying a Form After PHP Validation 371 Test Your Knowledge Table of Contents 17. Using Ajax.... What Is Ajax? Using XMLHttpRequest Implementing Ajax via POST Requests The readyState Property The Server Half of the Ajax Process Using GET Instead of POST Sending XMI. Requests About XMI Why Use XML? 373 Using Frameworks for Ajax Test Your Knowledge 18. Introduction to CSS Importing a Style Sheet Importing a Style Sheet from Within HTML Embedded Style Settings Using IDs Using Classes CSS Rules Using Semicolons Multiple Assignments Using Comments Style Types Default Styles User Styles External Style Sheets Internal Styles Inline Styles CSS Selectors The Type Selector The Child Selector The Descendant Selector The Adjacent Sibling Selector The ID Selector The Class Selector 171 374 376 378 379 381 383 385 387 387 387 389 390 390 391 391 391 392 392 392 393 394 394 394 394 395 395 396 396 396 397 398 399 399 400 400 401 402 402 402 403 The Attribute Selector The Universal Selector Selecting by Group The CSS Cascade Style Sheet Creators Style Sheet Methods Style Sheet Selectors Table of Contents | The Difference Berween