Register · · Password forgotten? · |
Nixon Robin - Learning PHP, MySQL & JavaScript: A Step-by-Step
|
![]() |
Home » Books and magazines » Computer literature » Web design and programming |
DL-List and Torrent activity | |
Size: 64 MB | Registered: 3 years | Completed: 1 time | |
|
Author | Message | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Download WYSIWYG ® Gender: Longevity: 10 years Posts: 1539 |
Learning PHP, MySQL & JavaScript: A Step-by-Step Guide to Creating Dynamic Websites (6th Edition)
Год издания: 2021 Автор: Nixon Robin Издательство: O'Reilly ISBN: 978-1-492-09382-4 Язык: Английский Формат: PDF/ePub Качество: Издательский макет или текст (eBook) Интерактивное оглавление: Да Количество страниц: 826 Описание: Build interactive, data-driven websites with the potent combination of open source technologies and web standards, even if you have only basic HTML knowledge. With the latest edition of this popular hands-on guide, you'll tackle dynamic web programming using the most recent versions of today's core technologies: PHP, MySQL, JavaScript, CSS, HTML5, jQuery, and the powerful React library. Web designers will learn how to use these technologies together while picking up valuable web programming practices along the way — including how to optimize websites for mobile devices. You'll put everything together to build a fully functional social networking site suitable for both desktop and mobile browsers.
ОглавлениеPreface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii1. Introduction to Dynamic Web Content. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 HTTP and HTML: Berners-Lee’s Basics 2 The Request/Response Procedure 2 The Benefits of PHP, MySQL, JavaScript, CSS, and HTML5 5 MariaDB: The MySQL Clone 6 Using PHP 6 Using MySQL 7 Using JavaScript 8 Using CSS 10 And Then There’s HTML5 10 The Apache Web Server 11 Handling Mobile Devices 12 About Open Source 12 Bringing It All Together 13 Questions 15 2. Setting Up a Development Server. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 What Is a WAMP, MAMP, or LAMP? 18 Installing AMPPS on Windows 18 Testing the Installation 23 Accessing the Document Root (Windows) 25 Alternative WAMPs 26 Installing AMPPS on macOS 27 Accessing the Document Root (macOS) 28 Installing a LAMP on Linux 29 Working Remotely 29 Logging In 30 Using SFTP or FTPS 30 Using a Code Editor 31 Using an IDE 32 Questions 34 3. Introduction to PHP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 Incorporating PHP Within HTML 35 This Book’s Examples 37 The Structure of PHP 37 Using Comments 37 Basic Syntax 38 Variables 39 Operators 44 Variable Assignment 48 Multiline 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 4. Expressions and Control Flow in PHP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 Expressions 63 TRUE or FALSE? 64 Literals and Variables 65 Operators 66 Operator Precedence 67 Associativity 69 Relational Operators 70 Conditionals 74 The if Statement 75 The else Statement 76 The elseif Statement 78 The switch Statement 79 The ? (or ternary) Operator 82 Looping 83 while Loops 84 do...while Loops 86 for Loops 86 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 5. PHP Functions and Objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 PHP Functions 96 Defining a Function 97 Returning a Value 98 Returning an Array 99 Passing Arguments by Reference 100 Returning Global Variables 102 Recap of Variable Scope 102 Including and Requiring Files 103 The include Statement 103 Using include_once 103 Using require and require_once 104 PHP Version Compatibility 104 PHP Objects 105 Terminology 106 Declaring a Class 107 Creating an Object 108 Accessing Objects 108 Cloning Objects 110 Constructors 111 Destructors 111 Writing Methods 112 Declaring Properties 113 Declaring Constants 114 Property and Method Scope 114 Static Methods 115 Static Properties 116 Inheritance 117 Questions 121 6. PHP Arrays. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 Basic Access 123 Numerically Indexed Arrays 123 Associative Arrays 125 Assignment Using the array Keyword 126 The foreach...as Loop 127 Multidimensional Arrays 129 Using Array Functions 132 is_array 132 count 133 sort 133 shuffle 133 explode 134 extract 135 compact 135 reset 137 end 137 Questions 137 7. Practical PHP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 Using printf 139 Precision Setting 140 String Padding 142 Using sprintf 143 Date and Time Functions 143 Date Constants 146 Using checkdate 146 File Handling 147 Checking Whether a File Exists 147 Creating a File 147 Reading from Files 149 Copying Files 150 Moving a File 150 Deleting a File 151 Updating Files 151 Locking Files for Multiple Accesses 152 Reading an Entire File 154 Uploading Files 155 System Calls 160 XHTML or HTML5? 162 Questions 163 8. Introduction to MySQL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 MySQL Basics 165 Summary of Database Terms 166 Accessing MySQL via the Command Line 166 Starting the Command-Line Interface 167 Using the Command-Line Interface 171 MySQL Commands 172 Data Types 177 Indexes 187 Creating an Index 187 Querying a MySQL Database 193 Joining Tables Together 203 Using Logical Operators 205 MySQL Functions 206 Accessing MySQL via phpMyAdmin 206 Questions 207 9. Mastering MySQL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 Database Design 209 Primary Keys: The Keys to Relational Databases 210 Normalization 211 First Normal Form 212 Second Normal Form 214 Third Normal Form 216 When Not to Use Normalization 218 Relationships 219 One-to-One 219 One-to-Many 220 Many-to-Many 221 Databases and Anonymity 222 Transactions 223 Transaction Storage Engines 223 Using BEGIN 224 Using COMMIT 225 Using ROLLBACK 225 Using EXPLAIN 226 Backing Up and Restoring 227 Using mysqldump 227 Creating a Backup File 229 Restoring from a Backup File 231 Dumping Data in CSV Format 231 Planning Your Backups 232 Questions 232 10. What’s New in PHP 8 and MySQL 8. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235 About This Chapter 235 PHP 8 236 Named Parameters 236 Attributes 237 Constructor Properties 237 Just-In-Time Compilation 238 Union Types 238 Null-safe Operator 238 match Expressions 238 New Functions 239 MySQL 8 243 Updates to SQL 243 JSON (JavaScript Object Notation) 244 Geography Support 244 Reliability 244 Speed and Performance 244 Management 245 Security 245 Questions 246 11. Accessing MySQL Using PHP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247 Querying a MySQL Database with PHP 247 The Process 247 Creating a Login File 248 Connecting to a MySQL Database 249 A Practical Example 254 The $_POST Array 257 Deleting a Record 258 Displaying the Form 258 Querying the Database 259 Running the Program 260 Practical MySQL 261 Creating a Table 262 Describing a Table 263 Dropping a Table 264 Adding Data 264 Retrieving Data 265 Updating Data 266 Deleting Data 267 Using AUTO_INCREMENT 267 Performing Additional Queries 269 Preventing Hacking Attempts 270 Steps You Can Take 271 Using Placeholders 273 Preventing JavaScript Injection into HTML 275 Questions 277 12. Form Handling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279 Building Forms 279 Retrieving Submitted Data 281 Default Values 282 Input Types 283 Sanitizing Input 290 An Example Program 292 HTML5 Enhancements 294 The autocomplete Attribute 295 The autofocus Attribute 295 The placeholder Attribute 295 The required Attribute 296 Override Attributes 296 The width and height Attributes 296 The min and max Attributes 296 The step Attribute 296 The form Attribute 297 The list Attribute 297 The color Input Type 297 The number and range Input Types 297 Date and Time Pickers 298 Questions 298 13. Cookies, Sessions, and Authentication. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299 Using Cookies in PHP 299 Setting a Cookie 301 Accessing a Cookie 302 Destroying a Cookie 302 HTTP Authentication 302 Storing Usernames and Passwords 306 An Example Program 308 Using Sessions 311 Starting a Session 312 Ending a Session 315 Setting a Timeout 316 Session Security 317 Questions 320 14. Exploring JavaScript. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321 JavaScript and HTML Text 322 Using Scripts Within a Document Head 323 Older and Nonstandard Browsers 324 Including JavaScript Files 324 Debugging JavaScript Errors 325 Using Comments 325 Semicolons 326 Variables 326 String Variables 327 Numeric Variables 327 Arrays 327 Operators 328 Arithmetic Operators 328 Assignment Operators 329 Comparison Operators 329 Logical Operators 330 Incrementing, Decrementing, and Shorthand Assignment 330 String Concatenation 330 Escape Characters 331 Variable Typing 331 Functions 333 Global Variables 333 Local Variables 333 Using let and const 334 The Document Object Model 337 Another Use for the $ Symbol 339 Using the DOM 340 About document.write 341 Using console.log 341 Using alert 341 Writing into Elements 341 Using document.write 341 Questions 342 15. Expressions and Control Flow in JavaScript. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343 Expressions 343 Literals and Variables 344 Operators 345 Operator Precedence 346 Associativity 346 Relational Operators 347 The with Statement 350 Using onerror 351 Using try...catch 352 Conditionals 353 The if Statement 353 The else Statement 353 The switch Statement 354 The ? Operator 356 Looping 357 while Loops 357 do...while Loops 357 for Loops 358 Breaking Out of a Loop 359 The continue Statement 359 Explicit Casting 360 Questions 361 16. JavaScript Functions, Objects, and Arrays. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363 JavaScript Functions 363 Defining a Function 363 Returning a Value 365 Returning an Array 367 JavaScript Objects 368 Declaring a Class 368 Creating an Object 370 Accessing Objects 370 The prototype Keyword 370 JavaScript Arrays 373 Numeric Arrays 374 Associative Arrays 375 Multidimensional Arrays 376 Using Array Methods 377 Questions 382 17. JavaScript and PHP Validation and Error Handling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385 Validating User Input with JavaScript 385 The validate.html Document (Part 1) 386 The validate.html Document (Part 2) 388 Regular Expressions 391 Matching Through Metacharacters 392 Fuzzy Character Matching 392 Grouping Through Parentheses 393 Character Classes 394 Indicating a Range 394 Negation 394 Some More Complicated Examples 395 Summary of Metacharacters 398 General Modifiers 399 Using Regular Expressions in JavaScript 400 Using Regular Expressions in PHP 400 Redisplaying a Form After PHP Validation 401 Questions 407 18. Using Asynchronous Communication. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409 What Is Asynchronous Communication? 410 Using XMLHttpRequest 410 Your First Asynchronous Program 411 Using GET Instead of POST 415 Sending XML Requests 417 Using Frameworks for Asynchronous Communication 421 Questions 421 19. Introduction to CSS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423 Importing a Stylesheet 424 Importing CSS from Within HTML 424 Embedded Style Settings 425 Using IDs 425 Using Classes 425 Using Semicolons 426 CSS Rules 426 Multiple Assignments 426 Using Comments 427 Style Types 428 Default Styles 428 User Styles 428 External Stylesheets 429 Internal Styles 429 Inline Styles 430 CSS Selectors 430 The Type Selector 430 The Descendant Selector 430 The Child Selector 431 The ID Selector 432 The Class Selector 433 The Attribute Selector 434 The Universal Selector 434 Selecting by Group 435 The CSS Cascade 436 Stylesheet Creators 436 Stylesheet Methods 436 Stylesheet Selectors 437 The Difference Between div and span Elements 439 Measurements 441 Fonts and Typography 443 font-family 443 font-style 444 font-size 444 font-weight 445 Managing Text Styles 445 Decoration 446 Spacing 446 Alignment 447 Transformation 447 Indenting 447 CSS Colors 448 Short Color Strings 448 Gradients 449 Positioning Elements 450 Absolute Positioning 450 Relative Positioning 451 Fixed Positioning 451 Pseudoclasses 453 Shorthand Rules 455 The Box Model and Layout 456 Setting Margins 456 Applying Borders 458 Adjusting Padding 459 Object Contents 461 Questions 461 20. Advanced CSS with CSS3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463 Attribute Selectors 464 Matching Parts of Strings 464 The box-sizing Property 465 CSS3 Backgrounds 466 The background-clip Property 466 The background-origin Property 468 The background-size Property 468 Using the auto Value 469 Multiple Backgrounds 469 CSS3 Borders 471 The border-color Property 471 The border-radius Property 471 Box Shadows 474 Element Overflow 475 Multicolumn Layout 475 Colors and Opacity 477 HSL Colors 477 HSLA Colors 478 RGB Colors 478 RGBA Colors 479 The opacity Property 479 Text Effects 479 The text-shadow Property 479 The text-overflow Property 479 The word-wrap Property 480 Web Fonts 481 Google Web Fonts 482 Transformations 483 3D Transformations 484 Transitions 485 Properties to Transition 485 Transition Duration 486 Transition Delay 486 Transition Timing 486 Shorthand Syntax 487 Questions 488 21. Accessing CSS from JavaScript. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491 Revisiting the getElementById Function 491 The O Function 491 The S Function 492 The C Function 493 Including the Functions 494 Accessing CSS Properties from JavaScript 494 Some Common Properties 495 Other Properties 496 Inline JavaScript 498 The this Keyword 498 Attaching Events to Objects in a Script 499 Attaching to Other Events 499 Adding New Elements 500 Removing Elements 502 Alternatives to Adding and Removing Elements 502 Using Interrupts 503 Using setTimeout 504 Canceling a Timeout 505 Using setInterval 505 Using Interrupts for Animation 507 Questions 509 22. Introduction to jQuery. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 511 Why jQuery? 512 Including jQuery 512 Choosing the Right Version 513 Downloading 514 Using a Content Delivery Network 514 Customizing jQuery 515 jQuery Syntax 515 A Simple Example 516 Avoiding Library Conflicts 517 Selectors 517 The css Method 517 The Element Selector 518 The ID Selector 519 The Class Selector 519 Combining Selectors 519 Handling Events 520 Waiting Until the Document Is Ready 521 Event Functions and Properties 522 The blur and focus Events 523 The this Keyword 524 The click and dblclick Events 524 The keypress Event 525 Considerate Programming 527 The mousemove Event 527 Other Mouse Events 530 Alternative Mouse Methods 531 The submit Event 532 Special Effects 533 Hiding and Showing 534 The toggle Method 535 Fading In and Out 536 Sliding Elements Up and Down 537 Animations 538 Stopping Animations 541 Manipulating the DOM 542 The Difference Between the text and html Methods 543 The val and attr Methods 543 Adding and Removing Elements 545 Dynamically Applying Classes 547 Modifying Dimensions 547 The width and height Methods 548 The innerWidth and innerHeight Methods 550 The outerWidth and outerHeight Methods 550 DOM Traversal 551 Parent Elements 551 Child Elements 555 Sibling Elements 555 Selecting the Next and Previous Elements 557 Traversing jQuery Selections 559 The is Method 560 Using jQuery Without Selectors 562 The $.each Method 562 The $.map Method 563 Using Asynchronous Communication 563 Using the POST Method 564 Using the GET Method 564 Plug-ins 565 jQuery User Interface 565 Other Plug-ins 566 Questions 566 23. Introduction to jQuery Mobile. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 569 Including jQuery Mobile 570 Getting Started 571 Linking Pages 573 Linking Synchronously 574 Linking Within a Multipage Document 574 Page Transitions 575 Styling Buttons 580 List Handling 582 Filterable Lists 583 List Dividers 585 What Next? 588 Questions 588 24. Introduction to React. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591 What Is the Point of React Anyway? 592 Accessing the React Files 593 Including babel.js 594 Our First React Project 595 Using a Function Instead of a Class 596 Pure and Impure Code: A Golden Rule 598 Using Both a Class and a Function 598 Props and Components 599 The Differences Between Using a Class and a Function 600 React State and Life Cycle 601 Using Hooks (if You Use Node.js) 604 Events in React 604 Inline JSX Conditional Statements 606 Using Lists and Keys 607 Unique Keys 608 Handling Forms 609 Using Text Input 610 Using textarea 612 Using select 613 React Native 615 Creating React Native Apps 615 Further Reading 615 Taking React to the Next Level 616 Questions 616 25. Introduction to HTML5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 619 The Canvas 619 Geolocation 621 Audio and Video 623 Forms 624 Local Storage 624 Web Workers 624 Questions 625 26. The HTML5 Canvas. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 627 Creating and Accessing a Canvas 627 The toDataURL Function 629 Specifying an Image Type 631 The fillRect Method 631 The clearRect Method 631 The strokeRect Method 632 Combining These Commands 632 The createLinearGradient Method 633 The addColorStop Method in Detail 635 The createRadialGradient Method 636 Using Patterns for Fills 638 Writing Text to the Canvas 640 The strokeText Method 640 The textBaseline Property 641 The font Property 641 The textAlign Property 641 The fillText Method 642 The measureText Method 643 Drawing Lines 643 The lineWidth Property 644 The lineCap and lineJoin Properties 644 The miterLimit Property 646 Using Paths 646 The moveTo and lineTo Methods 647 The stroke Method 647 The rect Method 648 Filling Areas 648 The clip Method 650 The isPointInPath Method 653 Working with Curves 654 The arc Method 654 The arcTo Method 657 The quadraticCurveTo Method 658 The bezierCurveTo Method 659 Manipulating Images 660 The drawImage Method 660 Resizing an Image 661 Selecting an Image Area 661 Copying from a Canvas 663 Adding Shadows 663 Editing at the Pixel Level 665 The getImageData Method 665 The putImageData Method 668 The createImageData Method 668 Advanced Graphical Effects 669 The globalCompositeOperation Property 669 The globalAlpha Property 672 Transformations 672 The scale Method 673 The save and restore Methods 674 The rotate Method 674 The translate Method 675 The transform Method 676 The setTransform Method 678 Questions 679 27. HTML5 Audio and Video. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 681 About Codecs 682 The Element 683 The Element 685 The Video Codecs 686 Questions 689 28. Other HTML5 Features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 691 Geolocation and the GPS Service 691 Other Location Methods 692 Geolocation and HTML5 693 Local Storage 696 Using Local Storage 696 The localStorage Object 697 Web Workers 699 Drag and Drop 702 Cross-Document Messaging 704 Other HTML5 Tags 708 Questions 708 29. Bringing It All Together. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 709 Designing a Social Networking App 710 On the Website 710 functions.php 710 The Functions 711 header.php 713 setup.php 716 index.php 718 signup.php 719 Checking for Username Availability 719 Logging In 720 checkuser.php 723 login.php 724 profile.php 726 Adding the “About Me” Text 727 Adding a Profile Image 727 Processing the Image 727 Displaying the Current Profile 728 members.php 731 Viewing a User’s Profile 732 Adding and Dropping Friends 732 Listing All Members 732 friends.php 735 messages.php 738 logout.php 741 styles.css 743 javascript.js 745 Questions 746 A. Solutions to the Chapter Questions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 747 Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 771
|
|||||||||||||||||||||
![]() |
Home » Books and magazines » Computer literature » Web design and programming |
Current time is: 08-Jun 09:39
All times are UTC + 2
You cannot post new topics in this forum
You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum |