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: An E-Commerce Approach

Book Description

Today's Web programmers are required to understand and use the tools and skills for both client and server-side programming. Web Programming and Internet Technologies: An E-Commerce Approach provides an accessible, comprehensive introduction to creating fully functioning websites with e-commerce capabilities. Ideal for the one-term course, or as a self-learning guide for professionals, the authors weave a continuing case study of a real-world commercial enterprise throughout the text that gradually grows in sophistication. Introductory chapters ask readers to create a simple website that uses the basic features of XHTML. Readers will continue to modify and expand their early work, creating a centralized mechanism for changing the look and feel of the site via cascading style sheets, and incorporating JavaScript, PHP, MySQL, and much more. A CD-ROM is included with every new printed copy of the text and includes complete and pre-tested XHTML and CSS markup for all web pages discussed, as well as all associated JavaScript and PHP scripts, and the data for setting up the MySQL database. With its hands-on, active-learning approach, students using this new full-color text will see, and experience first-hand, the many levels and capabilities of programming for the world wide web. Key Features: -Based on a real business model, this text provides a comprehensive introduction to all aspects of creating a complete website with e-commerce capabilities. -Uses a project-based approach that asks readers to develop a website whose functionality will parallel that of the real-world case study in the text. -Includes examples and screen shots of real websites throughout for readers to reference. -Presents and utilizes maintstream and relevant open-source and widely used technologies: XHTML, CSS, JavaScript, PHP, MySQL, XML, and more. -Every chapter concludes with a collection of activities to assure the reader has a full understanding of the chapter material. These activities include: quick questions to test the readers basic knowledge of the content; short exercises to improve basic understanding; 'exercises on the parallel project' that guide the reader through creating his/her own fully functional commercial website; a section titled 'What Else You May Want or Need to Know', containing additional information relevant to the chapter; and finally, a reference section with links to websites for further details and explanations of the topics covered in the chapter. -The accompanying CD-ROM contains complete and pre-tested XHTML and CSS markup for all web pages discussed in teh text, as well as all associated JavaScript and PHP scripts, and the data for setting up the MySQL database (eBook version doe not include the CD-ROM).

Table of Contents

  1. Cover
  2. Title Page
  3. Copyright
  4. Contents
  5. Dedication
  6. Preface
  7. Typographic and Other Conventions
  8. 1 Setting the Scene
    1. 1.1 Overview and Objectives
    2. 1.2 What Is the Internet?
    3. 1.3 What Is the World Wide Web (WWW)?
    4. 1.4 What Is Meant by a Client-Server Architecture?
    5. 1.5 How Do Web Browsers and Web Servers Fit the Client-Server Model?
    6. 1.6 How Do Web Browsers and Web Servers Communicate?
      1. 1.6.1 Web Protocols and Layered Communication Architectures
      2. 1.6.2 Web Addresses and Address Resolution via DNS
      3. 1.6.3 URLs, URNs, and URIs
    7. 1.7 A Real-World E-Commerce Website
    8. 1.8 What Are the Technologies We Will Discuss?
    9. 1.9 Summary
    10. 1.10 Quick Questions to Test Your Basic Knowledge
    11. 1.11 Short Exercises to Improve Your Basic Understanding
    12. 1.12 Exercises on the Parallel Project
    13. 1.13 What Else You May Want or Need to Know
    14. 1.14 References
  9. 2 Establishing a Web Presence
    1. 2.1 Overview and Objectives
    2. 2.2 What Is an Internet Service Provider (ISP)?
    3. 2.3 What Tools Will You Need to Begin Your Web Development?
    4. 2.4 How Do You Create a Simple, Static Web Page?
    5. 2.5 How Do You Test a Web Page “Offline” Before “Going Live”?
    6. 2.6 How Do You “Go Live” on the Web Once You’re Ready?
    7. 2.7 Summary
    8. 2.8 Quick Questions to Test Your Basic Knowledge
    9. 2.9 Short Exercises to Improve Your Basic Understanding
    10. 2.10 Exercises on the Parallel Project
    11. 2.11 What Else You May Want or Need to Know
    12. 2.12 References
  10. 3 XHTML for Content Structure
    1. 3.1 Overview and Objectives
    2. 3.2 Once There Was HTML, Now There Is XHTML
    3. 3.3 A Very Important Distinction: Structure vs. Presentation
    4. 3.4 XHTML Tags and Elements
    5. 3.5 What Is the Basic Structure of Every Web Page?
    6. 3.6 Some Basic Markup: Headings, Paragraphs, Line Breaks, and Lists
    7. 3.7 Tables, Images, and Tag Attributes
    8. 3.8 XHTML Entities
    9. 3.9 Adding More Web Pages to Our Site and Connecting Them with Hyperlinks
      1. 3.9.1 A Menu of Hyperlinks
      2. 3.9.2 Our Site Now Has Many Pages
    10. 3.10 Using Server Side Includes (SSI) to Make Common Markup Available to Multiple Documents
    11. 3.11 What Does It Mean for a Web Page to Be Valid?
    12. 3.12 How Can We Determine if a Web Page Is Valid?
    13. 3.13 Summary
    14. 3.14 Quick Questions to Test Your Basic Knowledge
    15. 3.15 Short Exercises to Improve Your Basic Understanding
    16. 3.16 Exercises on the Parallel Project
    17. 3.17 What Else You May Want or Need to Know
    18. 3.18 References
  11. 4 CSS for Content Presentation
    1. 4.1 Overview and Objectives
    2. 4.2 Why CSS?
    3. 4.3 Simple CSS Style Rules and Their Syntax
    4. 4.4 Where Do You Place Your CSS Style Rules?
    5. 4.5 A Simple Example
    6. 4.6 Some Basic CSS Markup: More on Selectors, Declarations, Properties, and Property Values
    7. 4.7 Some Common Types of CSS Property Values and Their Formats
      1. 4.7.1 Specifying Font Sizes and Lengths
      2. 4.7.2 Specifying Colors
      3. 4.7.3 The Important Takeaway from This Section
    8. 4.8 CSS Style Sheet Structure, Comments, and Formatting
    9. 4.9 The XHTML class and id Attributes and the XHTML div and span Elements
      1. 4.9.1 The XHTML class and id Attributes (CSS class and id Selectors)
      2. 4.9.2 The XHTML div and span Elements
      3. 4.9.3 Using Our Class Definitions
    10. 4.10 What About the “Cascading” Part of Cascading Style Sheets?
      1. 4.10.1 Inheritance
      2. 4.10.2 The “Cascade” and Resolution of Style Conflicts
      3. 4.10.3 Applying the Theory to Our Example
    11. 4.11 The CSS Box Model and Simple CSS Page Layout
      1. 4.11.1 The CSS Box Model
      2. 4.11.2 Simple CSS Page Layout with float and clear
    12. 4.12 CSS Reset: A “Best Practice”
    13. 4.13 Styling Our Nature’s Source Website with CSS
      1. 4.13.1 First, Our Simple Home Page
      2. 4.13.2 Second, Our Expanded Site with Its Home Page Menu and Footer and Additional Linked Pages
    14. 4.14 Validating Our CSS Style Sheets
    15. 4.15 Summary
    16. 4.16 Quick Questions to Test Your Basic Knowledge
    17. 4.17 Short Exercises to Improve Your Basic Understanding
    18. 4.18 Exercises on the Parallel Project
    19. 4.19 What Else You May Want or Need to Know
    20. 4.20 References
  12. 5 XHTML Forms for Data Collection and Submission
    1. 5.1 Overview and Objectives
    2. 5.2 Forms for Collecting User Input Data in the Browser and Sending It to the Server for Processing
    3. 5.3 The form Element
      1. 5.3.1 A Brief Aside, a Reminder, and Some Good Advice
      2. 5.3.2 How Will We Deal with CSS from Now On?
    4. 5.4 The input Element
      1. 5.4.1 Textboxes (input Elements of Type text)
      2. 5.4.2 Radio Buttons (input Elements of Type radio)
      3. 5.4.3 Checkboxes (input Elements of Type checkbox)
    5. 5.5 The select and option Elements for Dropdown List-Boxes
    6. 5.6 What Is Missing from the BMI Calculator Web Page?
    7. 5.7 The textarea Element
    8. 5.8 The submit and reset Button Elements
    9. 5.9 Organizing Form Controls with the fieldset and legend Elements
    10. 5.10 Using the label Element for Behind-the-Scenes Logical Groupings
    11. 5.11 Getting Ready to Submit Your Form Data
    12. 5.12 Summary
    13. 5.13 Quick Questions to Test Your Basic Knowledge
    14. 5.14 Short Exercises to Improve Your Basic Understanding
    15. 5.15 Exercises on the Parallel Project
    16. 5.16 What Else You May Want or Need to Know
    17. 5.17 References
  13. 6 JavaScript for Client-Side Computation and Data Validation
    1. 6.1 Overview and Objectives
    2. 6.2 Another Important Distinction: Structure vs. Presentation vs. Behavior
    3. 6.3 What Is JavaScript? (It’s not Java!)
      1. 6.3.1 JavaScript Is Interpreted, Not Compiled
      2. 6.3.2 Restrictions on What JavaScript Can Do
      3. 6.3.3 How Will We Use JavaScript?
    4. 6.4 A Simple JavaScript Example: User Notification with an Embedded Script
    5. 6.5 Where Do You Place Your JavaScript Code?
      1. 6.5.1 The Simple Example Revisited: Linking to an External Script
      2. 6.5.2 User Notification Revisited: The alert() Method
      3. 6.5.3 JavaScript Escape Characters
    6. 6.6 What Is the Document Object Model (DOM)?
    7. 6.7 How Do JavaScript and the DOM Interact?
      1. 6.7.1 A First Programmer-Defined JavaScript Function
      2. 6.7.2 JavaScript Variables
      3. 6.7.3 Accessing a DOM Element via Its id Attribute
      4. 6.7.4 Making Decisions with the JavaScript if-else Statement
      5. 6.7.5 Accessing a DOM Element via Its name Attribute
    8. 6.8 The Importance of Website Security
    9. 6.9 How Can JavaScript Help Address the Security Issue?
      1. 6.9.1 A First Look at JavaScript Arrays (in the Context of the DOM)
      2. 6.9.2 Accessing DOM Elements for the Purpose of Validating User Input
      3. 6.9.3 Evaluating Compound Boolean Expressions
      4. 6.9.4 Functions for Validating Numerical Input
      5. 6.9.5 Functions for Validating String Input: A First Look at Regular Expressions in JavaScript
    10. 6.10 Calculating the BMI: Numerical Calculations in JavaScript
    11. 6.11 JavaScript and Regular Expressions
    12. 6.12 Summary
    13. 6.13 Quick Questions to Test Your Basic Knowledge
    14. 6.14 Short Exercises to Improve Your Basic Understanding
    15. 6.15 Exercises on the Parallel Project
    16. 6.16 What Else You May Want or Need to Know
    17. 6.17 References
  14. 7 JavaScript for Client-Side Content Behavior
    1. 7.1 Overview and Objectives
    2. 7.2 A Revised Home Page with a “Slide Show” of Rotating Images and Dropdown Menu Options
    3. 7.3 Implementing Our “Slide Show” of Rotating Images
      1. 7.3.1 The onload Attribute of the body Element: Starting the Slide Show When the Home Page Loads
      2. 7.3.2 The Revised img Element for the Slide Show
      3. 7.3.3 The rotate.js Script
    4. 7.4 Implementing Our Dropdown Menus
      1. 7.4.1 An Overview of How Our Dropdown Menus Work
      2. 7.4.2 The onmouseover and onmouseout Attributes: Showing and Hiding Dropdown Menu Options
      3. 7.4.3 The CSS for Our Dropdown Menus
      4. 7.4.4 The JavaScript for Our Dropdown Menus: The show() and hide() Functions
    5. 7.5 The Footer Menu
    6. 7.6 Notes on the nature2 Version of Our Nature’s Source Site
    7. 7.7 Summary
    8. 7.8 Quick Questions to Test Your Basic Knowledge
    9. 7.9 Short Exercises to Improve Your Basic Understanding
    10. 7.10 Exercises on the Parallel Project
    11. 7.11 What Else You May Want or Need to Know
    12. 7.12 References
  15. 8 PHP for Server-Side Preprocessing
    1. 8.1 Overview and Objectives
    2. 8.2 Some PHP History
    3. 8.3 PHP as a Server-Side Scripting Language
    4. 8.4 PHP Script Structure and General Syntax: A Simple Example
      1. 8.4.1 The PHP date() Function
      2. 8.4.2 Generating and Displaying the Output from welcome.php
    5. 8.5 PHP Development and Testing
    6. 8.6 Incorporating the Welcome Message into Our Home Page
      1. 8.6.1 Refreshing a Page to Keep the Time Current
    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 the 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 the Confirmation Message to the Client with mail()
      8. 8.7.8 Returning the Browser Display for Immediate Confirmation of Feedback Submission to the User
      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
      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 PHP Code 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 XHTML-Encoded E-mail BMI Report to the User with Another Programmer-Defined Function
    9. 8.9 Summary
    10. 8.10 Quick Questions to Test Your Basic Knowledge
    11. 8.11 Short Exercises to Improve Your Basic Understanding
    12. 8.12 Exercises on the Parallel Project
    13. 8.13 What Else You May Want or Need to Know
    14. 8.14 References
  16. 9 MySQL for Server-Side Data Storage
    1. 9.1 Overview and Objectives
    2. 9.2 Relational Databases
    3. 9.3 Database Design Goals
    4. 9.4 Some Architectural Aspects of a “Good” Database
      1. 9.4.1 Database Normalization
      2. 9.4.2 Database Keys: Primary and Foreign, Natural and Surrogate, Simple and Composite
      3. 9.4.3 Functional Dependencies and 2NF
      4. 9.4.4 Table Relationships in a Database
      5. 9.4.5 Some General Advice
    5. 9.5 Make Use of Online Resources and Don’t Reinvent the Wheel
    6. 9.6 The Data Model for Our Nature’s Source Database
    7. 9.7 Using SQL and phpMyAdmin to Set Up the MySQL Database
      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
    9. 9.9 Importing and Exporting Tables and Databases
      1. 9.9.1 Copying a Table
      2. 9.9.2 Copying an Entire Database
      3. 9.9.3 Potential Problem with Importing via phpMyAdmin
    10. 9.10 Summary
    11. 9.11 Quick Questions to Test Your Basic Knowledge
    12. 9.12 Short Exercises to Improve Your Basic Understanding
    13. 9.13 Exercises on the Parallel Project
    14. 9.14 What Else You May Want or Need to Know
    15. 9.15 References
  17. 10 PHP and MySQL for Client-Server Database Interaction
    1. 10.1 Overview and Objectives
    2. 10.2 PHP and MySQL
    3. 10.3 Registration
      1. 10.3.1 Getting Valid Data from the User via the Registration Form
      2. 10.3.2 Submitting the Form Data: Possible Outcomes
      3. 10.3.3 Actual Processing of the Registration, with Valid Form Data
    4. 10.4 Logging In and Logging Out
      1. 10.4.1 PHP Arrays: We Need to Know More about Them
      2. 10.4.2 Logging In: The Logic of login.php
      3. 10.4.3 Logging Out: The Logic of logout.php
    5. 10.5 An E-Store Session After a Successful Login
    6. 10.6 Browsing Our E-Store Product Catalog
      1. 10.6.1 Displaying a Two-Column List of Products
      2. 10.6.2 Displaying Individual Products within a Category
    7. 10.7 Purchasing Products
      1. 10.7.1 A High-Level View of the processPurchase.php Script
      2. 10.7.2 Recalling the Relevant Tables in Our Database Structure
      3. 10.7.3 Getting the Product Details of an Existing Order with the getExistingOrder() Function
      4. 10.7.4 Creating a New Order with the createOrder() Function
      5. 10.7.5 Displaying the Header and Footer of the Shopping Cart Table with the displayHeader() and displayFooter() Functions
      6. 10.7.6 Displaying the Product Information in the Shopping Cart with the displayFirstFourColumns(), displayExistingItem(), and displayNewItem() Functions
      7. 10.7.7 Adding an Item to the Shopping Cart
      8. 10.7.8 Deleting an Item from the Shopping Cart
    8. 10.8 Checkout
    9. 10.9 Summary
    10. 10.10 Quick Questions to Test Your Basic Knowledge
    11. 10.11 Short Exercises to Improve Your Basic Understanding
    12. 10.12 Exercises on the Parallel Project
    13. 10.13 What Else You May Want or Need to Know
    14. 10.14 References
  18. 11 XML (eXtensible Markup Language) for Data Description
    1. 11.1 Overview and Objectives
    2. 11.2 The Basic Rules of XML
    3. 11.3 Describing Our Data with Well-Formed XML
      1. 11.3.1 Nested Elements vs. Tag Attributes
      2. 11.3.2 And What Does it Mean for Our XML to Be “Well-Formed”?
    4. 11.4 Viewing Our Raw (Unstyled) XML Data in a Browser
      1. 11.4.1 What Happens if Our XML Document Is Not Well-Formed?
    5. 11.5 Validating Our XML Data with a Document Type Definition
      1. 11.5.1 Connecting an XML Document to Its DTD: DOCTYPE Revisited
      2. 11.5.2 A Simple DTD Anatomy Lesson
      3. 11.5.3 More DTD Anatomy
      4. 11.5.4 Do You Really Need a DTD for Your XML Document?
      5. 11.5.5 Validating Your XML Document Against Your DTD, if You Have One
    6. 11.6 Styling Our XML Data with CSS
    7. 11.7 Isolating Our XML Tag Sets within XML Namespaces
    8. 11.8 Transforming Our XML Data with XSL, XSLT, and XPath
      1. 11.8.1 How Does XSLT Compare with CSS for Styling?
      2. 11.8.2 Our Example in Detail: How Does XSLT Use XML Namespaces and XPath to Do Its Job?
    9. 11.9 Summary
    10. 11.10 Quick Questions to Test Your Basic Knowledge
    11. 11.11 Short Exercises to Improve Your Basic Understanding
    12. 11.12 Exercises on the Parallel Project
    13. 11.13 What Else You May Want or Need to Know
    14. 11.14 References
  19. 12 Collecting, Analyzing, and Using Visitor Data
    1. 12.1 Overview and Objectives
    2. 12.2 Web-Server Access Logs
      1. 12.2.1 Format of Web-Server Access Logs
      2. 12.2.2 An Extended Log-File Format
      3. 12.2.3 An Example: Apache Web-Server Access Log Entries
    3. 12.3 Analysis of Web-Server Access Logs
      1. 12.3.1 Summarization of Web-Server Access Logs Using Analog
      2. 12.3.2 Clickstream Analysis: Studying Navigation Paths with Pathalizer
      3. 12.3.3 Visualizing Individual User Sessions with StatViz
    4. 12.4 Caution in Interpreting Web-Server Access Logs
    5. 12.5 Summary
    6. 12.6 Quick Questions to Test Your Basic Knowledge
    7. 12.7 Short Exercises to Improve Your Basic Understanding
    8. 12.8 Exercises on the Parallel Project
    9. 12.9 What Else You Might Want or Need to Know
    10. 12.10 References
  20. List of Figures
  21. Index
  22. Credits