Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations

Presentation on theme: "Web development 8.4.2013. Web development Content Part I: Server-side scripting Part II: Client-side scripting."— Presentation transcript:

1 Web development

2 Web development

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

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

5 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!



8 Data fetching

9 Data fetching

10 Inserting data

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

12 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

13 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

14 JSON in PHP

15 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]; }

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

17 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

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

19 Submit data from HTML to PHP

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

21 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.

22 HTML Basic website structure: Hello HTML Hello World!

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

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

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

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

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

28 JQuery example Click to slide down panel Hello world!

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

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

31 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

32 GoogleMaps example Google Maps JavaScript API Example: Simple Map

Ads by Google