Web development 8.4.2013. Web development Content Part I: Server-side scripting Part II: Client-side scripting.

Slides:



Advertisements
Similar presentations
HTML and CSS. HTML Hyper Text Markup Language Tells browser how to display text and images.
Advertisements

ASP.NET Intro An introduction to the languages and communication of an ASP.NET system.
Presenter: James Huang Date: Sept. 26,  Introduction  Basics  Lists  Links  Forms  CSS 2.
HTTP Request/Response Process 1.Enter URL ( in your browser’s address bar. 2.Your browser uses DNS to look up IP address of server.com.
JQuery A Javascript Library Hard things made eas(ier) Norman White.
Web Pages and Style Sheets Bert Wachsmuth. HTML versus XHTML XHTML is a stricter version of HTML: HTML + stricter rules = XHTML. XHTML Rule violations:
Instructional Technology & Design Office or Insert Workshop Name Presented by Your Name Here.
Understand Web Page Development Software Development Fundamentals LESSON 4.1.
IS 360 Course Introduction. Slide 2 What you will Learn (1) The role of Web servers and clients How to create HTML, XHTML, and HTML 5 pages suitable for.
4.01B Authoring Languages and Web Authoring Software 4.01 Examine webpage development and design.
Chapter 2 Introduction to HTML5 Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
Chapter 14 Introduction to HTML
INTRO TO MAKING A WEBSITE Mark Zhang.  HTML  CSS  Javascript  PHP  MySQL  …That’s a lot of stuff!
It’s World Wide! I NTRODUCTION TO T HE WEB 1 Photo courtesy:
Web Design Basic Concepts.
Web Page Introduction. What is a web page? A web page is a text file containing markup language tags. –A markup language combines text and extra information.
Chapter 9 Collecting Data with Forms. A form on a web page consists of form objects such as text boxes or radio buttons into which users type information.
© 2012 Adobe Systems Incorporated. All Rights Reserved. LEARNING THE LANGUAGE OF THE WEB INTRODUCTION TO HTML AND CSS.
Lecture 3 – Data Storage with XML+AJAX and MySQL+socket.io
What is Web Design?  Web design is the creation of a Web page using hypertext or hypermedia to be viewed on the World Wide Web.
Application Development Description and exemplification of server-side scripting language for server connection, database selection, execution of SQL queries.
Introduction to PHP and Server Side Technology. Slide 2 PHP History Created in 1995 PHP 5.0 is the current version It’s been around since 2004.
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
Chris Pinski.  History  What is Ajax  Who uses Ajax  Underlying Technologies  SE Aspect  Common Problems  Conclusion.
_______________________________________________________________________________________________________________ E-Commerce: Fundamentals and Applications1.
Creating a Basic Web Page
Internet and Web Application Development Revision.
Copyright © cs-tutorial.com. Introduction to Web Development In 1990 and 1991,Tim Berners-Lee created the World Wide Web at the European Laboratory for.
Chapter 16 The World Wide Web Chapter Goals Compare and contrast the Internet and the World Wide Web Describe general Web processing Describe several.
How to create a website with HTML and PHP The very basics By Alexander Niehoff.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
CS 215 Web Oriented Programming Review Dr. Orland Hoeber orland
18 People Surveyed HTML (HyperText Markup Language) HTML “tags” Describes structure Building blocks Headings, paragraphs, lists, links, images, quotes,
Styling and theming Build campaigns in style. What we'll look at... How a web document is structured How HTML and CSS fit together Tools you will need.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
Web Page Introduction. What is a web page? A web page is a text file containing markup language tags. –A markup language combines text and extra information.
Patroklos Patroklou George Antoniou Constantinos Kyprianou.
CSS CSS is short for C ascading S tyle S heets. It is a new web page layout method that has been added to HTML to give web developers more control over.
Tutorial 10 Programming with JavaScript
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
Website Development with PHP and MySQL Saving Data.
Session I Chapter 1 - Introduction to Web Development
Web Design (1) Terminology. Coding ‘languages’ (1) HTML - Hypertext Markup Language - describes the content of a web page CSS - Cascading Style Sheets.
Where does PHP code get executed?. Where does JavaScript get executed?
Session: 1. © Aptech Ltd. 2Introduction to the Web / Session 1  Explain the evolution of HTML  Explain the page structure used by HTML  List the drawbacks.
Advanced Web Development Instructor: Thomas Bombach.
JQuery Introduction © Copyright 2014, Fred McClurg All Rights Reserved.
Unleash the Power of jQuery Learning & Development Team Telerik Software Academy.
Introduction to CSS. Why CSS? CSS Provides Efficiency in Design and Updates CSS relatively easy to use Can give you more flexibility and control Faster.
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
AJAX Asynchronous JavaScript and XML 1. AJAX Outline What is AJAX? Benefits Real world examples How it works 2.
Introduction to HTML. _______________________________________________________________________________________________________________ 2 Outline Key issues.
ASP-2-1 SERVER AND CLIENT SIDE SCRITPING Colorado Technical University IT420 Tim Peterson.
Higher Computing Science Coding the Web: HTML, JavaScript, PHP and MySQL.
COSC 2328 – Web Programming.  PHP is a server scripting language  It’s widely-used and free  It’s an alternative to Microsoft’s ASP and Ruby  PHP.
Overview Web Technologies Computing Science Thompson Rivers University.
HTML Introduction HTML Editors HTML Basic HTML Elements HTML Attributes HTML Headings HTML Paragraphs HTML Formatting HTML Links HTML Head HTML CSS HTML.
CSS (Cascading Style Sheets). CSS CSS – Cascading Style Sheets – Cascade because of the way CSS rules can stack on top of each other. Allows you to add.
Web Development. Agenda Web History Network Architecture Types of Server The languages of the web Protocols API 2.
Web Technologies Computing Science Thompson Rivers University
ISC440: Web Programming 2 Web Programming Revision
INTRODUCTION TO HTML AND CSS
PHP –MySQL Interview Question And Answer.
WEB PAGE AUTHORINHG AND DESIGNING
Cascading Style Sheets (Introduction)
Web Technologies Computing Science Thompson Rivers University
PHP By Prof. B.A.Khivsara Note: The material to prepare this presentation has been taken from internet and are generated only for students reference and.
ADTEL WEBSITE
Presentation transcript:

Web development

Web development

Content Part I: Server-side scripting Part II: Client-side scripting

Part I Server-side scripting – PHP – MySQL – JSON

PHP - server-side scripting language - can be embedded to a HTML page - is interpreted at the server - generates HTML and can be embedded in it -requires php extension for website Hello!

PHP

MySQL CREATE TABLE Users ( ID INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(ID), UserName VARCHAR(20),...) INSERT INTO Users (UserName,...) VALUE (’aaa’,...) SELECT * FROM ’Users’

Data fetching <?php $con = mysqli_connect("localhost", "mopsi", "pswd", "database"); If ( mysqli_connect_errno() ) { echo "Failed to connect to MySQL"; } $result = mysqli_query($con, "SELECT ID, UserName FROM Users"); while ( $row = mysqli_fetch_array($result) ) { echo $row['ID']. " ". $row['UserName']; echo " "; } mysqli_close($con); ?>

Data fetching

Inserting data <?php $con = mysqli_connect("localhost", "mopsi", "pswd", "database"); if ( mysqli_connect_errno() ) { echo "Failed to connect to MySQL"; } mysqli_query($con, "INSERT INTO Users (ID, UserName, Password) VALUES ('435', 'matti', '23#sg5')"); mysqli_close($con); ?>

JSON A data-interchange format Easy for humans to read and write Easy for machines to parse and generate A lightweight alternative to XML

JSON Key-value pairs: {"request_type":"get_routes","user_id":"260","st art_time":" ","end_time":" "} keyvalue request_typeget_routes user_id260 start_time end_time

JSON An array can contain multiple objects: {"users":[{ "ID":"14","UserName":"Juha"},{"ID":"15","Use rName":"Jukka"},{"ID":"18","UserName":"karol "}]} [key]IDUserName 014Juha 115Jukka 218karol

JSON in PHP <?php $con = mysqli_connect("localhost","uname","pword","paikkaprojekti"); $rows = array(); If ( mysqli_connect_errno() ) { echo "Failed to connect to MySQL"; } $result = mysqli_query($con, "SELECT ID, UserName FROM Users"); while( $row = mysqli_fetch_assoc($result) ) { $rows[] = $row; } print json_encode($rows); mysqli_close($con); ?>

JSON in JavaScript var jsonInfo = '{"request_type":"init_mopsi"}'; var jsonString = initMopsi(jsonInfo); var jsonObject = eval("(" + jsonString + ")"); if (jsonObject.latitude != "") { g_latitude = jsonObject.latitude[0]; g_longitude = jsonObject.longitude[0]; }

Submit data from HTML to PHP POST is sent in the HTTP message body POST /mopsi/register.php HTTP/1.1 Host: cs.uef.fi uName=matti&pWord=asd#22d GET is sent in the URL of a GET request /mopsi/register.php?uName=matti&pWord=asd#22d

POST vs GET GETPOST BACK button/ReloadHarmlessData will be re-submitted BookmarkedCan be bookmarkedCannot be bookmarked CachedCan be cachedNot cached Restrictions on data lengthmax URL length (2048 characters) no restrictions Restrictions on data typeASCII onlyNo restrictions (also binary) Security/visibilityData is part of the URL (visible) A bit safer as params are not stored in browser history or in web server logs

Submit data from HTML to PHP Username: Password: In registration.php values are in: $_POST[uName] and $_POST[pWord]

Submit data from HTML to PHP <?php $userName = $_POST[uName]; $passWord = $_POST[pWord]; //TODO: insert credentials into DB echo "Welcome $userName!"; ?>

Part II Client-side scripting – HTML – CSS – JavaScript (including JQuery)

HTML A markup language for creating web pages to be displayed in a web browser Consists of tags enclosed in angle brackets (like ) The purpose of a web browser is to read HTML documents and compose them into visible or audible web pages. The browser does not display the HTML tags, but uses the tags to interpret the content of the page.

HTML Basic website structure: Hello HTML Hello World!

HTML Useful tags: Ordinary link: Link-text goes here Image-link: table header table data

CSS A style sheet language Used to separate content from its presentation Consists of a list of rules – Selectors – Declarations

CSS example body { background-color: #d0e4fe; font-family: "Sans"; font-size: 20px; } #regForm { color: orange; text-align: center; }

JQuery A JavaScript library Designed to make easier to... – navigate in a document – select DOM elements – handle events – create animations

JavaScript vs JQuery JavaScript: var container = document.getElementById('container'); JQuery: $('#container');

JQuery example Click to slide down panel Hello world!

JQuery example #panel, #flip { padding: 5px; text-align: center; background-color: #e5eecc; border: solid 1px #c3c3c3; } #panel { padding: 50px; display: none; }

JQuery example $(document).ready(function(){ $("#flip").click(function() $("#panel").slideDown("slow"); });

GoogleMaps API v3 API access to GoogleMaps -in web pages, in mobile apps -map tiles + overlays + events -geocoding -distances -directions Free unless commercial use is intended

GoogleMaps example Google Maps JavaScript API Example: Simple Map <script src="//maps.google.com/maps?file=api&v=2&sensor=false&key=AIzaSyD4iE2xV SpkLLOXoyqT-RuPwURN3ddScAI" type="text/javascript"> var map; function initialize() { if (GBrowserIsCompatible()) { map = new GMap2(document.getElementById("map_canvas")); map.setCenter(new GLatLng( , ), 13); map.setUIToDefault(); }

GoogleMaps example

GoogleMaps markers Google Maps JavaScript API Example: Simple Markers <script src="//maps.google.com/maps?file=api&v=2&key=AIzaSyD4iE2xVSpkLLOXoyqT- RuPwURN3ddScAI" type="text/javascript"> function initialize() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map_canvas")); map.setCenter(new GLatLng( , ), 13); // Add 10 markers to the map at random locations var bounds = map.getBounds(); var southWest = bounds.getSouthWest(); var northEast = bounds.getNorthEast(); var lngSpan = northEast.lng() - southWest.lng(); var latSpan = northEast.lat() - southWest.lat(); for (var i = 0; i < 10; i++) { var latlng = new GLatLng(southWest.lat() + latSpan * Math.random(), southWest.lng() + lngSpan * Math.random()); map.addOverlay(new GMarker(latlng)); }

GoogleMaps markers

GoogleMaps polylines Google Maps JavaScript API Example: Simple Polyline <script src="//maps.google.com/maps?file=api&v=2&key=AIzaSyD4iE2xVSp kLLOXoyqT-RuPwURN3ddScAI" type="text/javascript"> function initialize() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map_canvas")); map.setCenter(new GLatLng( , ), 13); var polyline = new GPolyline([ new GLatLng( , ), new GLatLng( , ) ], "#ff0000", 10); map.addOverlay(polyline); }

GoogleMaps polylines

GoogleMaps example

Cross browser compatibility Market share: Chrome (41%), IE (30%), Firefox (21%), Safari (9%), Opera (1%) IE causes problems: different properties of HTML elements, differences between versions

Developer tools Firefox, Chrome Developer Tool, IE Developer Console (not very handy, difficult to point out error source) An add-on for Firefox Highly useful in web development Can be used for inspecting -CSS -HTML -JavaScript -Net requests

Firebug

Chrome Developer Tool

Useful links HTML CSS JavaScript Jquery Google Maps API PHP