Claus Brabrand, ITU, Denmark SCRIPTING, DATABASES, & SYSTEM ARCHITECTURE Dec 16, 2011 Claus Brabrand ((( [email protected]))) Associate Professor, Ph.D. ((( Programming, Logic, and Semantics ))) IT University of Copenhagen introduction to SCRIPTING, DATABASES, SYSTEM ARCHITECTURE EVEN MORE WEB SERVICE EXAMPLES
24
Embed
introduction to SCRIPTING DATABASES SYSTEM ARCHITECTURE · Claus Brabrand, ITU, Denmark SCRIPTING, DATABASES, & SYSTEM ARCHITECTURE [ 3 ] Dec 16, 2011 Web Service: Quiz 1) Data Model:
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Claus Brabrand, ITU, Denmark SCRIPTING, DATABASES, & SYSTEM ARCHITECTURE Dec 16, 2011
Claus Brabrand ((( [email protected] ))) Associate Professor, Ph.D. ((( Programming, Logic, and Semantics ))) IT University of Copenhagen
introduction to SCRIPTING, DATABASES, SYSTEM ARCHITECTURE
EVEN MORE WEB SERVICE EXAMPLES
[ 2 ] Claus Brabrand, ITU, Denmark SCRIPTING, DATABASES, & SYSTEM ARCHITECTURE Dec 16, 2011
Agenda
n Web Service: Quiz n Web Service: ITU Project Broker (A9) n About the Exam n Questions
[ 3 ] Claus Brabrand, ITU, Denmark SCRIPTING, DATABASES, & SYSTEM ARCHITECTURE Dec 16, 2011
Web Service: Quiz 1) Data Model:
2) Data Transact's:
3)
qid question answer wrong1 wrong2
1 What is the average rainfall in Amazon basin?
2000 mm per year
200 mm per year
20000 mm per year
2 Who won the EURO 92? Denmark Germany France
questions:
INSERT INTO questions (question, answer, wrong1, wrong2) VALUES ('Is it Friday?', 'Yes', 'No', 'Maybe') ; SELECT * FROM questions ;
Select questions: Add quesion:
AUTO
Site
map
:
[ 4 ] Claus Brabrand, ITU, Denmark SCRIPTING, DATABASES, & SYSTEM ARCHITECTURE Dec 16, 2011
Create Tables
CREATE TABLE questions ( qid INT PRIMARY KEY AUTO_INCREMENT, question TEXT NOT NULL, answer TEXT NOT NULL, wrong1 TEXT NOT NULL, wrong2 TEXT NOT NULL );
qid question answer wrong1 wrong2
1 What is the average rainfall in Amazon basin?
2000 mm per year
200 mm per year
20000 mm per year
2 Who won the EURO 92? Denmark Germany France
questions:
AUTO
[ 5 ] Claus Brabrand, ITU, Denmark SCRIPTING, DATABASES, & SYSTEM ARCHITECTURE Dec 16, 2011
start.html <html> <body> <h3>Welcome to the Quizzzzzz</h3> <a href="add_q.html">ADD question</a> <p/> <a href="quiz.php">TAKE quiz</a> </body> </html>
[ 6 ] Claus Brabrand, ITU, Denmark SCRIPTING, DATABASES, & SYSTEM ARCHITECTURE Dec 16, 2011
INSERT INTO projects (title, description, ...) VALUES ('Man on the Moon', 'We need to...', ...) ;
SELECT * FROM projects ORDER BY title ;
Select all projects:
Add project:
AUTO
SELECT * FROM projects WHERE pid = '7';
Select specific project: UPDATE projects SET description = '..', title = '..' WHERE pid = '7';
Update specific project:
password
title
Site
map
:
[ 14 ] Claus Brabrand, ITU, Denmark SCRIPTING, DATABASES, & SYSTEM ARCHITECTURE Dec 16, 2011
Create Tables
CREATE TABLE projects ( pid INT PRIMARY KEY AUTO_INCREMENT, title VARCHAR(255) NOT NULL UNIQUE, description TEXT NOT NULL, name VARCHAR(100) NOT NULL, email VARCHAR(100) NOT NULL, password VARCHAR(10) NOT NULL );
pid title description name email password
1 Man on Mars We need to put a man on Mars before China. Email for details.
Barack Obama
obama@ hotmail.com
top*secret
2 Freedom of speech demo
We are organizing a demo against the freedom of speech!
[ 19 ] Claus Brabrand, ITU, Denmark SCRIPTING, DATABASES, & SYSTEM ARCHITECTURE Dec 16, 2011
update_project.php <?php include("fn_mydb_connect.php"); include("fn_input_validation.php"); mydb_connect(); $pid = $_REQUEST['pid']; $title = $_REQUEST['title']; $description = $_REQUEST['description']; $password = $_REQUEST['password']; chk_heltal($pid); chk_text_multi_line($title); chk_text_multi_line($description); chk_text_multi_line($password); // get password from database $rows = mysql_query("SELECT * FROM projects WHERE pid = '$pid';"); $row = mysql_fetch_array($rows); if ($row == NULL) { error("No such Project!"); } $database_password = $row['password']; if ($password != $database_password) { error("Password incorrect!"); } mysql_query("UPDATE projects SET title = '$title', description = '$description' WHERE pid = '$pid';"); header("Location: projects.php"); mysql_close(); ?>
[ 20 ] Claus Brabrand, ITU, Denmark SCRIPTING, DATABASES, & SYSTEM ARCHITECTURE Dec 16, 2011
Agenda
n Web Service: Quiz n Web Service: ITU Project Broker (A9) n About the Exam n Questions
[ 21 ] Claus Brabrand, ITU, Denmark SCRIPTING, DATABASES, & SYSTEM ARCHITECTURE Dec 16, 2011
Intended Learning Outcomes After the course, the student is expected to be able to…:
n plan and develop medium sized web applications using the scripting language, PHP;
n design small MySQL databases; n construct PHP scripts that interact with databases via SQL; n describe the techniques behind DB-driven web applications; n describe the fundamental system architectural
considerations behind web applications so as to be able to communicate and collaborate with programmers and technologists.
[ 22 ] Claus Brabrand, ITU, Denmark SCRIPTING, DATABASES, & SYSTEM ARCHITECTURE Dec 16, 2011
Exam
n 48-hour take-home exam: n From: Wednesday, January 18, 2012 at 13:00 n To: Friday, January 20, 2012 at 13:00
n Design + Develop a Web Service n (using the four steps + description)
[ 23 ] Claus Brabrand, ITU, Denmark SCRIPTING, DATABASES, & SYSTEM ARCHITECTURE Dec 16, 2011
Previous Exam Assignments
n Movie Subscription Service n Online Coffee Shop n Online Shoe Shop n Appartments 4 Rent n News Archive n Buy'n'Sell Service n Bike 2 Work Service n Vote About It
Claus Brabrand, ITU, Denmark SCRIPTING, DATABASES, & SYSTEM ARCHITECTURE Dec 16, 2011