Three tier achitecture

Download Report

Transcript Three tier achitecture

Web sites based on data
• What is it?
– Large Web sites that support commercial
use cannot be written by hand
• What you’re going to learn
– How a Web server and a database can be
used to generate web pages from data.
– Some systems that provide the necessary
functionality
– How a simple example looks in code.
Web sites based on data
Web Client / user
1. User
requests
a page
Web Server
2. HTTP request sent
3. SQL query
Runs program
or script
Response
Web page
on screen
Database server
data returned
4. Server
executes
query
5. Server script
copies data in
HTML format
The “three tier architecture”
Some technologies to use
Web Client / user
Web Server
Database server
Any Web browser
Client languages:
HTML, CSS,
JavaScript
Apache (most popular)
Server language:
MySQL
PHP
Query language:
SQL
Bundled in the
package
In practice: code
<html>
…
<body>
<h1>PHP and MySQL databases</h1>
<?php
$con = mysql_connect(“hostname","user","password");
mysql_select_db(“databasename", $con);
?>
The lines in red are server commands,
Embedded in the HTML code.
http://www.boisvert.me.uk/run/elcid.html?
file=users/charles/PHP_and_MySQL.xml
(http://localhost/run/elcid.html?file=users/charles/PHP_and_MySQL.xml)
Web sites based on data
• What is it?
– Large Web sites that support commercial use
are written by programming the Web server to
generate pages from database data
• What you’ve learnt
– The three-tier architecture supports dataoriented web sites
– The open-source XAMPP package contains
the necessary software
– PHP server scripting is embedded within
HTML code to program the system.