Web Programming Tutorial

Slides:



Advertisements
Similar presentations
PHP I.
Advertisements

Lecture 11 Server Side Interaction
SWU, Computer systems and technologies. The Objective of This Lecture To give you a very high-level overview of some of the tools for Web Programming.
Server-Side vs. Client-Side Scripting Languages
Introduction to Web Interface Technology (CSE2030)
Web Page Behavior IS 373—Web Standards Todd Will.
Introduction to Web Interface Technology (CSE2030)
INTRO TO MAKING A WEBSITE Mark Zhang.  HTML  CSS  Javascript  PHP  MySQL  …That’s a lot of stuff!
2440: 141 Web Site Administration Web Server-Side Programming Professor: Enoch E. Damson.
INTRODUCTION TO WEB DATABASE PROGRAMMING
Server- Side technologies Client-side vs. Server-side scripts PHP basic ASP.NET basic ColdFusion.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
INTERNET APPLICATION DEVELOPMENT For More visit:
Languages in WEB Presented by: Jenisha Kshatriya BCM SS09.
Chapter 1: Introduction to Web
Chapter 16 The World Wide Web Chapter Goals Compare and contrast the Internet and the World Wide Web Describe general Web processing Describe several.
IDK0040 Võrgurakendused I harjutus 06: PHP: Introduction Deniss Kumlander.
Chapter 16 The World Wide Web. 2 The Web An infrastructure of information combined and the network software used to access it Web page A document that.
NASRULLAH KHAN.  Lecturer : Nasrullah   Website :
10/5/2015CS346 PHP1 Module 1 Introduction to PHP.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
JavaScript – Quiz #9 Lecture Code:
Active Server Pages  In this chapter, you will learn:  How browsers and servers interacted on the Internet when the Internet first became popular 
Kingdom of Saudi Arabia Ministry of Higher Education Al-Imam Muhammad Ibn Saud Islamic University College of Computer and Information Sciences Chapter.
Introduction to PHP Advanced Database System Lab no.1.
1 MSCS 237 Overview of web technologies (A specific type of distributed systems)
Web Programming Brian Toone 8/27/2014. Outline for today 1.Understanding the architecture of the web 2.Overview of programming languages – Client-side.
ASP. What is ASP? ASP stands for Active Server Pages ASP is a Microsoft Technology ASP is a program that runs inside IIS IIS stands for Internet Information.
By Tharith Sriv. To write a web page you use: HHTML (HyperText Markup Language), AASP (Active Server Page), PPHP (HyperText Preprocessor), JJavaScript,
David Lawrence 7/8/091Intro. to PHP -- David Lawrence.
Introduction and Principles Web Server Scripting.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
NASRULLAH KHAN.  Lecturer : Nasrullah   Website :
 Web pages originally static  Page is delivered exactly as stored on server  Same information displayed for all users, from all contexts  Dynamic.
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.
National College of Science & Information Technology.
1 Chapter 1 INTRODUCTION TO WEB. 2 Objectives In this chapter, you will: Become familiar with the architecture of the World Wide Web Learn about communication.
PHP using MySQL Database for Web Development (part II)
Web Programming Language
Tonga Institute of Higher Education IT 141: Information Systems
Web Technologies Computing Science Thompson Rivers University
JavaScript and Ajax (Ajax Tutorial)
Introduction to Dynamic Web Programming
Section 6.3 Server-side Scripting
Chapter 5 Scripting Language
WWW and HTTP King Fahd University of Petroleum & Minerals
Introduction and Principles
* Lecture # 7 Instructor: Rida Noor Department of Computer Science
Introduction to Web Programming
Chapter 5 Scripting Language
AJAX.
PHP / MySQL Introduction
8th Semester, Batch 2008 Department of Computer Science SSUET.
PHP Introduction.
DB Programming on the Web
Introduction to Web Database By Rimpi Suman 1 1 Unit-6.
Chapter 27 WWW and HTTP.
Tonga Institute of Higher Education IT 141: Information Systems
Module 1 Introduction to PHP 11/30/2018 CS346 PHP.
Tonga Institute of Higher Education IT 141: Information Systems
IntroductionToPHP Static vs. Dynamic websites
Chapter 16 The World Wide Web.
Intro to PHP.
Tutorial 10: Programming with javascript
BOF #1 – Fundamentals of the Web
PHP an introduction.
Web Technologies Computing Science Thompson Rivers University
Web Servers (IIS and Apache)
Web Application Development Using PHP
Presentation transcript:

Web Programming Tutorial Slides Designed by Tao Cheng Augmented & Presented by Rui Li CS 411, Spring 2011

Announcements There are 6 Feedback questions regarding this status of this class. PLEASE respond to these survey questions, so that we may improve the class. –https://agora.cs.illinois.edu/display/cs411sp11/Feedback

What is Web Development? Web development is a broad term for any activity related to developing a web site for the World Wide Web or an intranet. Usually refers to the non-design aspects of writing markup and coding

Why Web Programming One of the choices for building applications around DBMS (the front end) Many database applications require easy access to serve the public

The Objective of This Lecture To give you a very high-level overview of some of the tools for Web Programming Use several typical tools to show the basics of Web Programming Not meant for advanced Web developers We will assume minimal interaction with DBMS in this lecture to focus on the Web programming part

Client Side Coding: Code that runs on the client side’s browsers HTML stands for HyperText Markup Language, and is the predominant markup language for web pages. It is written in the form of HTML elements consisting of "tags" surrounded by angle brackets within the web page content Javascript Formally called EMCAScript, Javascript is a ubiquitous client side programming tool, often implemented as part of a web browser in order to provide enhanced user interfaces and dynamic websites. It’s typically used to enable programmatic access to computational objects within a host environment. Applet and ActiveX. Applet (e.g. Java Applet): small application that performs one specific task, sometimes running within a larger program, perhaps as a plug-in. AJAX (Asynchronous Javascript And XML) Group of technologies that provides new methods of using Javascript, PHP and other languages to improve the user experience

Server Side Coding: Code that runs on the server’s side CGI (standard protocol for server-client communication) PHP (open source) ASP.NET (Microsoft proprietary) JSP (JavaServer Pages) Python, e.g. Django (web framework) (open source) Ruby, e.g. Ruby on Rails (open source)

“LAMP”: Open Source Solution, Bundle of Software Linux, referring to the operating system; Apache, the Web server; MySQL, the database management system (or database server); PHP or others, i.e., Perl, Python, the programming languages LAMP is easy to code locally and deploy, allows for cheap & ubiquitous hosting

Plan of the Lecture Client Programming HTML + Javascript Server Side programming using PHP (as in the LAMP architecture) Additional tools: Ajax, etc Demo

Representing Data with HTML HTML is a language for describing web pages. HTML stands for Hyper Text Markup Language HTML is not a programming language, it is a markup language A markup language is a set of markup tags HTML uses markup tags to describe web pages

HTML Basics <h1>This is a heading</h1> <a href="http://www.illinois.edu">This is a link</a> <img src="w3schools.jpg" width="104" height="142" /> <form> First name: <input type="text" name="firstname" /> </form>

Creating a simple html file at projects.cs.illinois.edu Go to your project page management site: http://accounts.cs.illinois.edu/projects. Web pages created here will appear at netid.cs.projects.illinois.edu Place a blank or “hello world” page called “test.html" and make sure that you can access it at http://netid.projects.cs.illinois.edu/test.html replace"netid” with your netid. Make sure to place all of this in the public_html folder, to have the file show up See my simple posted example file: http://ruili1.projects.cs.illinois.edu/test.html

JavaScript JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting language. JavaScript is usually embedded directly into HTML pages JavaScript is an interpreted language (means that scripts execute without preliminary compilation)

Javascript The HTML <script> tag is used to insert a JavaScript into an HTML page. Caution! Javascript may be browser dependent <html> <body> <script type="text/javascript"> document.write("Hello World!"); </script> </body> </html>

What JavaScript can do JavaScript can put dynamic text into an HTML page - A JavaScript statement like this: document.write("<h1>" + name + "</h1>") can write a variable text into an HTML page JavaScript can react to events - A JavaScript can be set to execute when something happens, like when a page has finished loading or when a user clicks on an HTML element

What JavaScript can do JavaScript can read and write HTML elements - A JavaScript can read and change the content of an HTML element JavaScript can be used to validate data - A JavaScript can be used to validate form data before it is submitted to a server. This saves the server from extra processing

Demo JavaScript http://ruili1.projects.cs.illinois.edu/demo1.html

What is “PHP”? Self-referentially short for PHP: Hypertext Preprocessor, an open source, server-side, HTML embedded scripting language used to create dynamic Web pages. PHP files can contain text, HTML tags and scripts PHP files are returned to the browser as plain HTML  PHP files have a file extension of ".php", ".php3", or ".phtml” Contrast with Javascript, which is client-side, HTML embedded scripting lanuage

PHP Hello World in browser Example of a simple HTML + PHP script which sends the text "Hello World" to the browser: There are two basic statements to output text with PHP: echo and print. In the example above we have used the echo statement to output the text "Hello World”. <html> <body> <?php echo "Hello World!; ?> </body> </html>

PHP Basics A type does not need to be specified in advance. A PHP file normally contains HTML tags, just like an HTML file, and some PHP scripting code A PHP scripting block always starts with <?php and ends with ?>. A PHP scripting block can be placed anywhere in the document. All variables in PHP start with a $ sign symbol. $var_name = value; A type does not need to be specified in advance. $x=16; $txt="Hello World!";

PHP Basics Numeric array – An array with a numeric index $cars=array("Saab“,"Volvo","BMW","Toyota"); $cars[0]="Saab"; $cars[1]="Volvo"; $cars[2]="BMW"; $cars[3]="Toyota";

PHP Basics Associated Arrays Arrays (syntax is: array(key => value), so create key-value pairs) <?php $a=array("a"=>"Dog","b"=>"Cat","c"=>"Horse"); print_r($a); ?> output: Array ( [a] => Dog [b] => Cat [c] => Horse )

PHP basics Multidimensional Arrays $families = array  ( "Griffin"=>array ("Peter", "Lois", "Megan"),   "Quagmire"=>array ("Glenn"), "Brown"=>array( "Cleveland", "Loretta", "Junior"));

PHP Basics if (condition) code to be executed if condition is true; for (init; condition; increment) {   code to be executed;   } function functionName() { code to be executed; }

Get User Input with GET and POST $_GET[“var”] if the url sent to the server (e.g. after a form submission looks like: http://www.w3schools.com/welcome.php?fname=Peter&age=37 The "welcome.php" file can now use the $_GET function to collect form data Welcome <?php echo $_GET["fname"]; ?> output: Displays “Welcome Peter” $_POST[“var”] similar to GET, but the information sent with a POST method is invisible, unlike if sent with GET method

Track Http State Http is a stateless protocol. It does not require the server to retain information or status about each user for the duration of multiple requests. The web application may have to track the user's progress from page to page. e.g., user login, items in a cart Solution: HTTP cookies. Server side Sessions

Using Cookies in PHP A cookie is often used to identify a user small file that the server embeds on the user's computer. Each time the same computer requests a page with a browser, it will send the cookie too. With PHP, you can both create and retrieve cookie values create a cookie: setcookie(name, value, expire, path, domain); The PHP $_COOKIE variable is used to retrieve a cookie value.

Using Session in PHP A PHP session variable is used to store information about settings for a user session. Session variables hold information about one single user, and are available to all pages in one application. session_start() creates a session or resumes the current one based on a session identifier passed via a GET or POST request, or passed via a cookie. To store and retrieve session variables, use the PHP $_SESSION variable

Cookie vs Session Cookie Session More permanent Typically small (need to be sent to server) Session Typically in server memory (ends when you close browser) Can be of any size

Demo http://ruili1.projects.cs.illinois.edu/test.html

AJAX Ajax, or AJAX (Asynchronous JavaScript and XML), is a group of interrelated web development techniques used to create interactive web applications or rich Internet applications. AJAX allows web pages to be updated asynchronously by exchanging small amounts of data with the server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page.

AJAX is Based on Internet Standards AJAX is based on internet standards, and uses a combination of: XMLHttpRequest object (to exchange data asynchronously with a server) JavaScript/DOM (to display/interact with the information) CSS (to style the data) XML (often used as the format for transferring data)   AJAX applications are browser- and platform-independent!

AJAX Suggestion Example Google Suggest is using AJAX to create a dynamic web interface: When you start typing in Google's search box, a JavaScript sends the letters off to a server and the server returns a list of suggestions. Note that the page does not reload as you type

ASP.net and JSP They follow pretty similar architecture ASP.net server side scripting technology that enables scripts (embedded in web pages) to be executed by an Internet server. normally used together with SQLServer (MS proprietary) JSP Roughly, allows Java code and certain pre-defined actions to be combined with static web markup content. The resulting page is compiled and executed on the server-side to deliver an HTML or XML document Since it’s Java, JSP is Orcale proprietary

Other Tools for Web Programming Django open source web application framework written in Python emphasizes reusability and "pluggability" of components, rapid development Ruby on Rails open source web application framework for the Ruby programming language similar philosophies of reusability, convention over configuration

Take Away Message Web Programming is not hard Many tutorials (with examples) available W3Schools is a great place to start: http://www.w3schools.com Choose your preferred tools early, and start to get familiar with them

References Getting starting with CGI Programming in C http://www.cs.tut.fi/~jkorpela/forms/cgic.html PHP related examples, including PHP + MySQL http://www.w3schools.com/php/ W3Schools tutorials are generally very helpful, on almost all the tools we covered Also for using PHP with MySQL: Hugh Williams and David Lane, ``Web Database Applications with PHP and MySQL'' http://www.webdatabasebook.com/