Cpcs110/notes/dynamic web content

Return to Notes

Contents

Basic Internet/Web Concepts

  • The Internet (uppercase I) is a vast network of networks of millions of computers linked together by various protocols.
  • TCP/IP (Transmission Control Protocol/Internet Protocol) are the protocols that govern how the Internet works. The TCP (transmission control protocol) protocol controls how data are transmitted across the network (TCP). The IP (internet protocol) determines how different types of networks (Ethernet, token ring, WiFi, ATM, etc.) communicate with each other.
  • The Web was invented by Tim Berners-Lee a fellow at CERN (the European Laboratory for Particle Physics). Rather than patenting or copyrighting his invention, he made it available freely and openly to everyone. This revolutionized the Internet making it accessible to the general public.
  • HTTP, the HyperText Transfer Protocol determines how content is handled on the Web. HTTP is the communication protocol between your computer, via the browser, and the various services you interact with. Basically the browser makes a request to the server and the server issues a response back to the browser.
  • Client-Server computing is an application architecture that divides the work between a service provider (such as Amazon or Google) and service consumers (such as your browser). Service providers utilize server software, the most popular of which is Apache.

How the Internet Works

Basic Client/Server Request/Response Protocol

Without PHP
The user types a URL into a browser. The URL is used to route the page to the correct server. The server looks up the page (directory.html) on its hard disk and returns the HTML-marked-up page to the browser.
  1. You enter http://someserver.com into your browser's address bar.
    The browser looks up the IP address for someserver.com (not shown).
  2. The browser issues a request for the home page at someserver.com.
    The request is routed across the Internet to someserver.com.
  3. The server receives the request.
  4. The server retrieves the requested page from its hard disk.
  5. The server returns the requested page to the browser.
  6. The browser renders or displays the page.

Languages and Systems We Will Learn To Use

HTML

  • HTML (HyperText Markup Language) is the predominant markup language for the WWW. It is organized as a collection of tags that describe a web page's static content and layout.
  • A very simple example.
<html>
<body>

<h1>Level 1 Heading</h1>

<p>A paragraph.</p>

</body>
</html> 
  • HTML Tutorial. We will have a lab and assignment on learning HTML and building our own web page. There are many good HTML tutorials on the Web. Just Google "HTML Tutorial." Here is another example: HTML Tutorial.

Javascript (We probably won't do very much)

  • Javascript is a client-side scripting language. Scripts are little programs that are interpreted either on the client side or server side of the interaction between client and sever. Javascript scripts are interpreted right in the browser before pages are sent to the web server. Here's an example script:
<script type="text/javascript">
document.write("Hello World. Today is " + Date());
</script>

This script would display the following content on the web page:

Hello World. Today is Mon Sep 14 2009 08:30:05

PHP Will Be Our Primary Programming Language

  • PHP is a free and open source server-side scripting language. The acronym originally stood for Personal Home Page but it was subsequently changed to PHP: Hypertext Preprocessor.
  • PHP script is embedded in a web page's HTML and allows the page to have dynamic content. Here's a simple example from the PHP Tutorial on the PHP web site that will display a level-1 HTML heading with Hello World.
<html>
 <head>
  <title>PHP Test</title>
 </head>
 <body>
 <?php echo '<h1>Hello World</h1>'; ?> 
 </body>
</html>
  • We will learn how to create dynamic web pages using PHP.

Apache Web Server

  • Apache is an open-source web server. It receives browser requests and returns an HTML-coded web page to the browser. If the HTML contains PHP code, the server interprets it and changes the content of the web page.
  • We will set up an Apache web server on our laptops during Week 2.

MySQL Database Language and Server

  • MySQL is the most widely used open-source relational database. It is based on SQL (Structured Query Language).
  • A relational database organizes data into tables that are interrelated by the certain shared columns (attributes). For example, the following tables are related via their shared school attribute.

nameschool
Porky PigTrinity
Donald DuckWesleyan
Users

schoolcity
TrinityHartford
WesleyanMiddletown
Schools
  • SQL is used to issue commands to the database server. We will learn to embed SQL commands into our PHP scripts.
INSERT INTO users VALUES ('Porky Pig', 'Trinity');
SELECT name FROM users WHERE school='Trinity';

How the Internet Works with PHP and MySQL

With PHP/MySQL
The user types a URL into a browser. The URL is used to route the page to the correct server. The server looks up the page (login.php) on its hard disk. Because this is a PHP file, the server invokes the PHP interpreter, which interprets and acts on the page's PHP code. In this case it asks the MySQL database to check the username and password and returns an appropriate HTML-marked-up page to the browser.
  1. You enter http://someserver.com into your browser's address bar.
    The browser looks up the IP address for someserver.com (not shown).
  2. The browser issues a request for the home page at someserver.com.
    The request is routed across the Internet to someserver.com.
  3. The Apache server receives the request.
  4. The Apache server retrieves the requested page from its hard disk.
  5. The Apache server extracts any PHP scripts from the page.
  6. The Apache server's PHP Interpreter interprets the PHP script (if any).
  7. The PHP Interpreter issues SQL commands to the MySQL DB server.
  8. The MySQL server returns some data to the server.
  9. The PHP Interpreter bundles the data together with the rest of the page.
  10. The server returns the data to the browser as an HTML-encoded web page.
  11. The browser interprets the HTML and displays the page.

More Details

  • For a more detailed and comprehensive overview of how the Internet and WWW work, see How the Internet Works.


Return to Notes