Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Chapter 2 Client/Server Applications 954240 Web Programming Modern Management and Information Technology College of Arts, Media and Technology, Chiang Mai University Contents • • • • Client/Server Design in Web Applications Working with Files and Folders What Languages Will I Use? What Software Will I Need? Client/Server Design in Web Applications Client/Server Design in Web Applications Recall from Chapter 1: • a client application provides an interface to the user and waits for the user to request some action • a client application calls a server application to process the request • a server application sends back a response • a client application receives the response and present to the user 4 Client/Server Design in Web Applications Example of client/server design Source: Mike O’Kane (2011) A Web-Based Introduction to Programming 5 Client/Server Design in Web Applications Recall from Chapter 1: • A single server can deliver the same services to any number of clients. • Changes can be made on the server with no need to make changes on the client (ex. update software on the server, not on every clients) • A Web application is an example of an Internetbased client/server design 6 Client/Server Design in Web Applications • To develop a Web-based applications: - We must create files that contain the instructions for our Web pages and store them on a Web server. - Then, the server can response to the requests. 7 Working with Files and Folders Working with Files and Folders In this course you will use different extensions for your files: • Plain text files • HTML files • PHP files 9 Working with Files and Folders • Plain text files - Using a .txt or .dat extension - Used to store simple data - Ex. you might create a file named “scores.txt” that contains a list of student scores. 10 Working with Files and Folders • HTML files - Using a .html extension - Used to store the markup instructions to allow the user to enter information - Ex. you might create a file named “wages.html“ that contains a Web page with a form for the user to submit their hours worked and hourly wage. 11 Working with Files and Folders • PHP files - Using a .php extension - Used to store the source code. PHP programs will receive information from the user or look up data in files to process operations and generate output. - Ex, you might create a file named “wages.php” that contains the source code to receive information, then calculate and display the pay. 12 Working with Files and Folders • Files are usually organized into folders for ease of management • You can access files on disks located in local drives (in your personal computer) • You can also access files on disks in remote disk drives, (in other computers => server) through a network such as the Internet 13 Working with Files and Folders • However, in this course, we will use a software that allows you to run a Web server on your local computer with no need for Internet access in order to work simply and securely 14 What Languages Will I Use? What Languages Will I Use? You will write your Web programs using a combination of two languages: • HTML (Hypertext Markup Language) • PHP (PHP Hypertext Preprocessor) 16 What Languages Will I Use? • HTML (Hypertext Markup Language) - Provides the markup instructions that you will use to create and format the Web pages that display the user interface for your Web applications - You will use HTML to display headings, paragraphs, forms, tables, buttons, and images - Everything you learn will be based on current HTML standards, which is known as XHTML 17 What Languages Will I Use? • PHP (PHP Hypertext Preprocessor) PHP is a programming language that you will use to write server-based program that process user requests by: - performing calculations - reading data from files/databases - validating input - writing output to files/databases - making decisions - returning results to the user, etc. 18 What Languages Will I Use? From an example of a simple client/server application from Chapter 1, there are two web pages: 1 2 Source: Mike O’Kane (2011) A Web-Based Introduction to Programming 19 What Languages Will I Use? • The first Web page is generated from HTML code located in an .html file on a Web server 1 A form that the user can enter information (input) and click a button 20 What Languages Will I Use? • When the user click the button, the browser sends the input (10.75 and 25) back to the server with a request to process a PHP code file • The PHP file receives input, calculates a wage based on the input, and generates a new HTML page to display the results (The second page) 21 What Languages Will I Use? • The second Web page is created by the PHP file and the server returns this to the Web browser for display to the user 2 22 What Languages Will I Use? 23 What Software Will I Need? What Software Will I Need? • A text editor to create HTML and PHP files. • A Web browser to submit requests to the Web server and display the result Web pages • A Web server that can process requests 25