O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Web Programming and Internet Technologies, 2nd Edition

Book Description

Web Programming and Internet Technologies: An E-Commerce Approach is written for the one-term web programming course for first or second year students. I features a hands-on learning approach where students are provided with information on a need to know basis. The text provides a running case study throughout, and students then take the topics taught in each chapter and apply them to the development of an e-commerce website. At the end of the text students will have a fully functional e-commerce site!

Table of Contents

  1. Cover Page
  2. Title Page
  3. Copyright Page
  4. Dedication
  5. Contents
  6. Preface
  7. Typographic and Other Conventions
  8. 1 Setting the Scene
    1. 1.1 What Is the Internet?
    2. 1.2 What Is the World Wide Web?
    3. 1.3 What Is Meant by a Client-Server Architecture?
    4. 1.4 How Do Web Browsers and Web Servers Fit the Client-Server Model?
    5. 1.5 How Do Web Browsers and Web Servers Communicate?
      1. 1.5.1 Web Protocols and Layered Communication Architectures
      2. 1.5.2 Web Addresses and Address Resolution via DNS
      3. 1.5.3 URLs, URNs, and URIs
    6. 1.6 A Real-World E-Commerce Website
    7. 1.7 The Technologies We Will Discuss
    8. 1.8 Some Alternative Technologies and Additional Tools
    9. Summary
    10. Quick Questions to Test Your Basic Knowledge
    11. Short Exercises to Improve Your Basic Understanding
    12. Exercises on the Parallel Project
    13. What Else You May Want or Need to Know
    14. References
  9. 2 Establishing a Web Presence
    1. 2.1 What Is an Internet Service Provider (ISP)?
    2. 2.2 What Tools Will You Need to Begin Your Web Development?
    3. 2.3 How Do You Create a Simple, Static Web Page?
    4. 2.4 How Do You Test a Web Page “Offline” before “Going Online”?
    5. 2.5 How Do You “Go Live” on the Web Once You’re Ready?
    6. Summary
    7. Quick Questions to Test Your Basic Knowledge
    8. Short Exercises to Improve Your Basic Understanding
    9. Exercises on the Parallel Project
    10. What Else You May Want or Need to Know
    11. References
  10. 3 HTML for Content Structure
    1. 3.1 The Long Road to HTML5, the New Norm
    2. 3.2 A Very Important Distinction: Structure vs. Presentation
    3. 3.3 HTML Tags and Elements
    4. 3.4 The Basic Structure of Every Web Page
    5. 3.5 Some Basic Markup: Headings, Paragraphs, Line Breaks, and Lists
    6. 3.6 What Does It Mean for a Web Page to Be Valid?
    7. 3.7 How Can We Determine if a Web Page Is Valid?
    8. 3.8 Validating with the Firefox Web Developer Add-on
    9. 3.9 Tables, Images, and Tag Attributes
    10. 3.10 HTML Entities
    11. 3.11 Adding More Web Pages to Our Site and Connecting Them with Hyperlinks
      1. 3.11.1 A Menu of Hyperlinks
      2. 3.11.2 Our Site Now Has Many Pages
      3. 3.11.3 Beware the “Legacy Fix”!
    12. 3.12 Using Server-Side Includes (SSI) to Make Common Markup Available to Multiple Documents
      1. 3.12.1 The “Maintenance Nightmare” Problem
      2. 3.12.2 Identifying and Extracting Common Markup
      3. 3.12.3 Using SSI to Include Common Markup Where Needed
      4. 3.12.4 One Thing Leads to Another: A Second Problem
      5. 3.12.5 The base Tag Solves Our Second Problem
      6. 3.12.6 Our Revised Site Looks and Behaves Exactly Like the Previous Version
    13. 3.13 The New HTML5 Semantic Elements
      1. 3.13.1 Block-level Elements and Inline-level Elements
      2. 3.13.2 Semantic Elements and Non-Semantic Elements
      3. 3.13.3 Two More Legacy Elements: div and span
      4. 3.13.4 New Semantic Elements in HTML5
    14. Summary
    15. Quick Questions to Test Your Basic Knowledge
    16. Short Exercises to Improve Your Basic Understanding
    17. Exercises on the Parallel Project
    18. What Else You May Want or Need to Know
    19. References
  11. 4 CSS for Content Presentation
    1. 4.1 The Rationale for CSS, and a Brief History
    2. 4.2 Simple CSS Style Rules and Their Syntax
    3. 4.3 The Placement of CSS Style Rules
    4. 4.4 A Simple Example
    5. 4.5 Some Basic CSS Markup: More on Selectors, Declarations, Properties, and Property Values
    6. 4.6 Some Common Types of CSS Property Values and Their Formats
      1. 4.6.1 Specifying Measurement Property Values
      2. 4.6.2 Specifying Color Property Values
      3. 4.6.3 The Important Takeaway from This Section
    7. 4.7 CSS Style Sheet Structure, Comments, and Formatting
    8. 4.8 The HTML class and id Attributes and the Non-Semantic HTML div and span Elements
      1. 4.8.1 The HTML class and id Attributes (CSS class and id Selectors)
      2. 4.8.2 The HTML div and span Elements
      3. 4.8.3 Using Our Class Definitions
    9. 4.9 Inheritance and the Cascade
      1. 4.9.1 Inheritance
      2. 4.9.2 The “Cascade” and Resolution of Style Conflicts
      3. 4.9.3 Applying the Theory to Our Example
    10. 4.10 Validating Our CSS Style Sheets
    11. 4.11 The CSS Box Model and Simple CSS Page Layout
      1. 4.11.1 The CSS Box Model: A Conceptual View
      2. 4.11.2 The CSS Box Model: A Detailed Example
      3. 4.11.3 Simple CSS Page Layout with float and clear via the “Legacy” Approach with div Elements
      4. 4.11.4 Simple CSS Page Layout with float and clear via the “Modern” Approach with HTML5 Semantic Elements
    12. 4.12 CSS Reset: A “Best Practice”
    13. 4.13 Styling Our Nature’s Source Website with CSS (Four Versions, Illustrating CSS3, Simple “Responsive Design”, and the New HTML5 video Element)
      1. 4.13.1 Version 1: A Simple Home Page Only
      2. 4.13.2 Version 2: A Multipage Site with Menu and Footer
      3. 4.13.3 Version 3: A Revision of Version 2 Incorporating Some CSS3 and Illustrating Simple “Responsive Design”
      4. 4.13.4 Version 4: A Copy of Version 3 with the Home Page Image Replaced by a Home Page Video
    14. Summary
    15. Quick Questions to Test Your Basic Knowledge
    16. Short Exercises to Improve Your Basic Understanding
    17. Exercises on the Parallel Project
    18. What Else You May Want or Need to Know
    19. References
  12. 5 HTML Forms for Data Collection
    1. 5.1 Web Forms Collect User Input Data in a Browser for Transfer to a Server for Processing
    2. 5.2 The form Element
      1. 5.2.1 A Brief Aside, a Reminder, and Some Good Advice
      2. 5.2.2 How Will We Deal with CSS from Now On?
    3. 5.3 The input Element
      1. 5.3.1 Textboxes (input Elements of Type text)
      2. 5.3.2 Radio Buttons (input Elements of Type radio)
      3. 5.3.3 Checkboxes (input Elements of Type checkbox)
    4. 5.4 The select and option Elements for Dropdown List-boxes
    5. 5.5 What Is Missing from the BMI Calculator Web Page?
    6. 5.6 The textarea Element
    7. 5.7 The submit and reset Button Elements
    8. 5.8 Organizing Form Controls with the fieldset and legend Elements
    9. 5.9 Using the label Element for Behind-the-Scenes Logical Groupings
    10. 5.10 Getting Ready to Submit Your Form Data
    11. 5.11 HTML5 Form Controls
    12. Summary
    13. Quick Questions to Test Your Basic Knowledge
    14. Short Exercises to Improve Your Basic Understanding
    15. Exercises on the Parallel Project
    16. What Else You May Want or Need to Know
    17. References
  13. 6 JavaScript for Client-Side Computation and Form Data Validation
    1. 6.1 Another Important Distinction: Structure vs. Presentation vs. Behavior
    2. 6.2 What Is JavaScript? (It’s not Java!)
      1. 6.2.1 JavaScript Is Interpreted, Not Compiled
      2. 6.2.2 Restrictions on What JavaScript Can Do
      3. 6.2.3 How Will We Use JavaScript?
    3. 6.3 The Placement of JavaScript Code
    4. 6.4 A Simple Example in Four Versions
      1. 6.4.1 Version 1: No JavaScript
      2. 6.4.2 Version 2: Embedded JavaScript and document.write( )
      3. 6.4.3 Version 3: Linking to an External JavaScript File
      4. 6.4.4 Version 4: Another External Script, the alert( ) Method, and Escape Characters
    5. 6.5 What Is the Document Object Model (DOM)?
    6. 6.6 JavaScript and the DOM Interact to Process Our BMI Form
      1. 6.6.1 A First Programmer-Defined JavaScript Function: Function Syntax
      2. 6.6.2 JavaScript Variables
      3. 6.6.3 Accessing a DOM Element via Its id Attribute
      4. 6.6.4 Making Decisions with the JavaScript if-else Statement
      5. 6.6.5 Accessing a DOM Element via Its name Attribute
    7. 6.7 The Importance of Website Security and How JavaScript Can Help
    8. 6.8 JavaScript and the DOM Interact to Validate Our BMI Form Data
      1. 6.8.1 Simple JavaScript Arrays, and the options Array of a select Element
      2. 6.8.2 Getting the Height and Weight Units Chosen by the User
      3. 6.8.3 Getting the User’s Height and Weight Values, and Email Address
      4. 6.8.4 Calling Functions to Validate Height, Weight, and Email Values
      5. 6.8.5 Logical Operators and Compound Boolean Expressions
      6. 6.8.6 Relational Operators and Functions for Validating Height and Weight Values
      7. 6.8.7 Simple Regular Expressions and a Function for Validating an Email Address
    9. 6.9 JavaScript and the DOM Interact to Compute a BMI Value
      1. 6.9.1 Numerical Calculations: Three Functions Compute the BMI Value
      2. 6.9.2 Setting the Precision of the BMI Value and Displaying a Detailed Report
    10. 6.10 Regular Expressions in JavaScript and in HTML5
    11. 6.11 JavaScript and the DOM Interact to Validate Our Feedback Form Data
      1. 6.11.1 Validating First and Last Names
      2. 6.11.2 Validating Telephone Numbers
      3. 6.11.3 Validating Email Addresses
    12. 6.12 The Modernizr Tool and HTML5 Form Controls
    13. Summary
    14. Quick Questions to Test Your Basic Knowledge
    15. Short Exercises to Improve Your Basic Understanding
    16. Exercises on the Parallel Project
    17. What Else You May Want or Need to Know
    18. References
  14. 7 JavaScript for Client-Side Content Behavior
    1. 7.1 Enhancing Our Website with a Home Page “Slide Show” of Rotating Images and Dropdown Menu Options on Every Page
    2. 7.2 Implementing Our “Slide Show” of Rotating Images
      1. 7.2.1 The onload Attribute of the body Element: Starting the Slide Show after the Home Page Loads
      2. 7.2.2 The Revised img Element for the Slide Show
      3. 7.2.3 The rotate.js Script
    3. 7.3 Implementing Our Dropdown Menus
      1. 7.3.1 An Overview of How Our Dropdown Menus Work
      2. 7.3.2 The onmouseover and onmouseout Attributes: Showing and Hiding Dropdown Menu Options
      3. 7.3.3 The CSS for Our Dropdown Menus
      4. 7.3.4 The JavaScript for Our Dropdown Menus: The show( ) and hide( ) Functions
    4. 7.4 Notes on the nature2 Version of Our Nature’s Source Website
      1. 7.4.1 What’s New in Our BMI Form?
      2. 7.4.2 What’s New in Our Feedback Form?
      3. 7.4.3 What’s Different about the nature2 Markup for Our Menu Bar?
    5. Summary
    6. Quick Questions to Test Your Basic Knowledge
    7. Short Exercises to Improve Your Basic Understanding
    8. Exercises on the Parallel Project
    9. What Else You May Want or Need to Know
    10. References
  15. 8 PHP for Server-Side Preprocessing
    1. 8.1 Some PHP History
    2. 8.2 PHP as a Server-Side Scripting Language
    3. 8.3 PHP Script Structure and General Syntax: A Simple First Example
      1. 8.3.1 The PHP date( ) Function
      2. 8.3.2 Generating and Displaying the Output from welcome.php
    4. 8.4 Why We Need AJAX and How We Use It: Two More Examples
      1. 8.4.1 What Is AJAX?
      2. 8.4.2 A Problem We Need to Solve: A “Page Refresh” Example
      3. 8.4.3 The Solution to Our Problem: An AJAX Example
    5. 8.5 Incorporating the Welcome Message into Our Home Page with AJAX
    6. 8.6 Understanding the GET and POST “Methods”
      1. 8.6.1 An Example Illustrating the GET Method
      2. 8.6.2 An Example Illustrating the POST Method
      3. 8.6.3 An Example Illustrating That a Form Is Unnecessary and GET Is the Default
      4. 8.6.4 Guidelines for Using GET and POST
    7. 8.7 Implementing the Server-Side Functionality of Our Feedback Form
      1. 8.7.1 What Happens When the User Clicks Send Feedback
      2. 8.7.2 Uploading the Feedback Form Data from the Client to the Server
      3. 8.7.3 An Overview of the PHP Code That Processes the Feedback Form Data
      4. 8.7.4 Building the Feedback Message to the Business with PHP String Literals and the $_POST Array Values
      5. 8.7.5 Sending an Email Feedback Message to the Business with PHP’s mail( ) Function
      6. 8.7.6 Modifying the Previous Message to the Business to Get One Suitable for the Client
      7. 8.7.7 Sending an Email Feedback Confirmation Message to the Client with PHP’s mail( ) Function
      8. 8.7.8 Returning a Browser Display to the User for Immediate Confirmation of Feedback Submission
      9. 8.7.9 Saving the User’s Feedback on the Server with PHP File Output
    8. 8.8 Revising the Implementation of Our BMI Calculator to Calculate Server-Side
      1. 8.8.1 What Happens When the User Clicks Compute your BMI
      2. 8.8.2 Uploading the BMI Form Data from the Client to the Server
      3. 8.8.3 An Overview of the “Driver” Script That Processes the BMI Form Data
      4. 8.8.4 Building the BMI Report Message with Programmer-Defined PHP Functions
      5. 8.8.5 Computing the BMI Value: Numerical Computations in PHP, and More Programmer-Defined Functions
      6. 8.8.6 Building and Sending an HTML-Encoded Email BMI Report to the User with Another Programmer-Defined Function
    9. 8.9 PHP Development and Testing
    10. Summary
    11. Quick Questions to Test Your Basic Knowledge
    12. Short Exercises to Improve Your Basic Understanding
    13. Exercises on the Parallel Project
    14. What Else You May Want or Need to Know
    15. References
  16. 9 MySQL for Server-Side Data Storage
    1. 9.1 Relational Databases
    2. 9.2 Database Design Goals
    3. 9.3 Some Architectural Aspects of a “Good” Database
      1. 9.3.1 Database Normalization
      2. 9.3.2 Database Keys: Primary and Foreign, Natural and Surrogate, Simple and Composite
      3. 9.3.3 Functional Dependencies and 2NF
      4. 9.3.4 Table Relationships in a Database
      5. 9.3.5 Some General Advice
    4. 9.4 Make Use of Online Resources and Don’t Reinvent the Wheel
    5. 9.5 The Data Model for Our Nature’s Source Database
    6. 9.6 MySQL, phpMyAdmin, and SQL
    7. 9.7 Using phpMyAdmin and SQL to Set Up the MySQL Database for Our Nature’s Source Website
      1. 9.7.1 The CREATE Command
      2. 9.7.2 The ALTER Command
      3. 9.7.3 The DROP Command
      4. 9.7.4 The INSERT Command
      5. 9.7.5 The LOAD Command
      6. 9.7.6 The UPDATE Command
      7. 9.7.7 A First Look at the SELECT Command
      8. 9.7.8 The DELETE Command
      9. 9.7.9 The TRUNCATE Command
      10. 9.7.10 Inventory Management Systems
    8. 9.8 MySQL’s Command-Line Interface
      1. 9.8.1 A First Session with the Command-Line Interface
      2. 9.8.2 A Closer Look at the SELECT Command
      3. 9.8.3 Restricting the Set of Records from Which We Retrieve Our Data
      4. 9.8.4 Retrieving Data from More Than One Table with a Join
    9. 9.9 Importing and Exporting Tables and Databases
      1. 9.9.1 Copying a Table or Part of a Table
      2. 9.9.2 Copying an Entire Database
      3. 9.9.3 Potential Problem with Importing via phpMyAdmin
    10. Summary
    11. Quick Questions to Test Your Basic Knowledge
    12. Short Exercises to Improve Your Basic Understanding
    13. Exercises on the Parallel Project
    14. What Else You May Want or Need to Know
    15. References
  17. 10 PHP and MySQL for Client-Server Database Interaction
    1. 10.1 PHP and MySQL
    2. 10.2 Registration
      1. 10.2.1 Getting Valid Registration Form Data from the User
      2. 10.2.2 Submitting the Form Data: Possible Outcomes
      3. 10.2.3 Actual Processing of the Registration, with Valid Form Data
    3. 10.3 Logging In and Logging Out
      1. 10.3.1 PHP Sessions Revisited: We Need to Know More about Them
      2. 10.3.2 PHP Arrays Revisited: We Need to Know More about Them
      3. 10.3.3 Logging In: The Logic of loginForm.php
      4. 10.3.4 Logging Out: The Logic of logout.php
    4. 10.4 An E-Store Session after a Successful Login
    5. 10.5 Browsing Our E-Store Product Catalog
      1. 10.5.1 Displaying a Two-Column List of Products
      2. 10.5.2 Displaying Individual Products within a Category
    6. 10.6 Purchasing Products
      1. 10.6.1 The pages/shoppingCart.php Script
      2. 10.6.2 A High-Level View of the scripts/shoppingCartProcess.php Script
      3. 10.6.3 Reviewing the Relevant Tables in Our Nature’s Source Database Structure
      4. 10.6.4 Getting the Product Details of an Existing Order with getExistingOrder( )
      5. 10.6.5 Creating a New Order with createOrder( )
      6. 10.6.6 Displaying the Header of the Shopping Cart Table with displayHeader( )
      7. 10.6.7 Displaying the Product Information in the Shopping Cart with FirstFourColumns( ), displayExistingItemColumns( ), and displayNewItemColumns( )
      8. 10.6.8 Displaying the Footer of the Shopping Cart Table with displayFooter( )
      9. 10.6.9 Adding an Item to the Shopping Cart with shoppingCartAddItem.php
      10. 10.6.10 Deleting an Item from the Shopping Cart with shoppingCartDeleteItem.php
    7. 10.7 Checkout
      1. 10.7.1 Displaying a Customer Receipt and Updating Our Database
      2. 10.7.2 Updating Our Database
      3. 10.7.3 Performing Some “Cleanup” During Logout
    8. 10.8 Some Utility Files for Use at the MySQL Command-Line Interface
    9. Summary
    10. Quick Questions to Test Your Basic Knowledge
    11. Short Exercises to Improve Your Basic Understanding
    12. Exercises on the Parallel Project
    13. What Else You May Want or Need to Know
    14. References
  18. 11 XML (eXtensible Markup Language) for Data Description
    1. 11.1 The Basic Rules of XML
    2. 11.2 Describing Our Data with Well-Formed XML
      1. 11.2.1 Nested Elements vs. Tag Attributes
      2. 11.2.2 And What Does It Mean for Our XML to Be “Well-Formed”?
    3. 11.3 Viewing Our Raw (Unstyled) XML Data in a Browser
      1. 11.3.1 What Happens If Our XML Document Is Not Well-Formed?
    4. 11.4 Validating Our XML Data with a Document Type Definition
      1. 11.4.1 Connecting an XML Document to Its DTD: DOCTYPE Revisited
      2. 11.4.2 A Simple DTD Anatomy Lesson
      3. 11.4.3 More DTD Anatomy
      4. 11.4.4 Do You Really Need a DTD for Your XML Document?
      5. 11.4.5 Validating Your XML Document Against Your DTD, If You Have One
    5. 11.5 Styling Our XML Data with CSS
    6. 11.6 Isolating Our XML Tag Sets within XML Namespaces
    7. 11.7 Transforming Our XML Data with XSL, XSLT, and XPath
      1. 11.7.1 How Does XSLT Compare with CSS for Styling?
      2. 11.7.2 Our Example in Detail: How Does XSLT Use XML Namespaces and XPath to Do Its Job?
    8. Summary
    9. Quick Questions to Test Your Basic Knowledge
    10. Short Exercises to Improve Your Basic Understanding
    11. Exercises on the Parallel Project
    12. What Else You May Want or Need to Know
    13. References
  19. 12 Collecting, Analyzing, and Using Visitor Data
    1. 12.1 Web-Server Access Logs
      1. 12.1.1 Format of Web-Server Access Logs
      2. 12.1.2 An Extended Log-File Format
      3. 12.1.3 An Example: Apache Web-Server Access Log Entries
    2. 12.2 Analysis of Web-Server Access Logs
      1. 12.2.1 Summarization of Web-Server Access Logs Using Analog
      2. 12.2.2 Clickstream Analysis: Studying Navigation Paths with Pathalizer
      3. 12.2.3 Visualizing Individual User Sessions with StatViz
    3. 12.3 Caution in Interpreting Web-Server Access Logs
    4. Summary
    5. Quick Questions to Test Your Basic Knowledge
    6. Short Exercises to Improve Your Basic Understanding
    7. Exercises on the Parallel Project
    8. What Else You Might Want or Need to Know
    9. References
  20. Index