Chapter 1 Introduction to web development and PHP



Similar documents
Introduction to web development and JavaScript

Chapter 1. Introduction to web development

Instructor: Betty O Neil

Introduction to web development

CEFNS Web Hosting a Guide for CS212

How to Configure edgebox as a Web Server

FireBLAST Marketing Solution v2

Lesson 7 - Website Administration

Getting Started with KompoZer

CREATING A NEWSLETTER IN ADOBE DREAMWEAVER CS5 (step-by-step directions)

Mapping ITS s File Server Folder to Mosaic Windows to Publish a Website

How To Use Dreamweaver With Your Computer Or Your Computer (Or Your Computer) Or Your Phone Or Tablet (Or A Computer)

Adobe Dreamweaver CC 14 Tutorial

Web Programming. Robert M. Dondero, Ph.D. Princeton University

AJ Matrix V5. Installation Manual

Using the CCNY Server Space with Secure Shell 3.0 for Windows Created by Doris Grasserbauer

Site Maintenance Using Dreamweaver

How To Create A Web Page On A Windows (For Free) With A Notepad) On A Macintosh (For A Freebie) Or Macintosh Web Browser (For Cheap) On Your Computer Or Macbook (

JJY s Joomla 1.5 Template Design Tutorial:

Using SSH Secure Shell Client for FTP

How To Set Up A Webhosting Website On Windstream.Com

Install FileZilla Client. Connecting to an FTP server

ITP 101 Project 3 - Dreamweaver

CTIS 256 Web Technologies II. Week # 1 Serkan GENÇ

Creating Web Pages with Netscape/Mozilla Composer and Uploading Files with CuteFTP

Microsoft FrontPage 2003

.NET Best Practices Part 1 Master Pages Setup. Version 2.0

We automatically generate the HTML for this as seen below. Provide the above components for the teaser.txt file.

OCS Training Workshop LAB13. Ethernet FTP and HTTP servers

WEB DEVELOPMENT IA & IB (893 & 894)

Getting Started using the SQuirreL SQL Client

Setting Up a Development Server

Contents. Downloading the Data Files Centering Page Elements... 6

Chapter 7 Page Layout Basics Key Concepts. Copyright 2013 Terry Ann Morris, Ed.D

Using Adobe Dreamweaver CS4 (10.0)

Setting Up Your FTP Server

Agenda. 1. ZAPms Konzept. 2. Benutzer-Kontroller. 3. Laout-Aufbau. 4. Template-Aufbau. 6. Konfiguration. 7. Module.

A send-a-friend application with ASP Smart Mailer

Web applications. Web security: web basics. HTTP requests. URLs. GET request. Myrto Arapinis School of Informatics University of Edinburgh

Dreamweaver CS5. Module 2: Website Modification

Uploading files to a web server using SSH Secure Shell 3.2.9

Introduction to Macromedia Dreamweaver MX

Microsoft Expression Web Quickstart Guide

CREATING HORIZONTAL NAVIGATION BAR USING ADOBE DREAMWEAVER CS5

TIMETABLE ADMINISTRATOR S MANUAL

Using SSH Secure FTP Client INFORMATION TECHNOLOGY SERVICES California State University, Los Angeles Version 2.0 Fall 2008.

IC3 Internet and Computing Core Certification Guide

Dreamweaver CS5. Module 1: Website Development

C O N F I G U R I N G Y O U R W E B B R O W S E R TO A L L O W P O P - U P W I N D O W S

Contents. Introduction Downloading the Data Files... 2

Lab 1: Create a Personal Homepage

Introduction Connecting Via FTP Where do I upload my website? What to call your home page? Troubleshooting FTP...

Joomla 1.0 Extension Development Training. Learning to program for Joomla

Web File Management with SSH Secure Shell 3.2.3

How-to: HTTP-Proxy and Radius Authentication and Windows IAS Server settings. Securepoint Security System Version 2007nx

Lab - Configure a Windows 7 Firewall

FileMaker Server 11. FileMaker Server Help

Installation Instructions

FileMaker 11. Instant Web Publishing Guide

Content Management System

HTML CSS Basic Structure. HTML Structure [Source Code] CSS Structure [Cascading Styles] DIV or ID Tags and Classes. The BOX MODEL

Appendix H: Cascading Style Sheets (CSS)

Further web design: Cascading Style Sheets Practical workbook

FileMaker 12. Instant Web Publishing Guide

Quick Start Guide Mobile Entrée 4

Flash MX Image Animation

Using Internet or Windows Explorer to Upload Your Site

Actiontec GT784WN Router

MassTransit 6.0 Enterprise Web Configuration for Macintosh OS 10.5 Server

Build it with Drupal 8

Internet Technologies. World Wide Web (WWW) Proxy Server Network Address Translator (NAT)

FileMaker Server 10 Help

Transferring Your Hosting Account

Introduction to Web Technologies

Application Note Configuring the UGate 3000 for use with ClipMail Pro and ClipExpress

Kentico CMS, 2011 Kentico Software. Contents. Mobile Development using Kentico CMS 6 2 Exploring the Mobile Environment 1

1. Hardware Installation

Monitoring Oracle Enterprise Performance Management System Release Deployments from Oracle Enterprise Manager 12c

A-AUTO 50 for Windows Setup Guide

Dashboard Builder TM for Microsoft Access

FileMaker Server 12. FileMaker Server Help

FileZilla: Uploading/Downloading Files to SBI FTP

Building a Horizontal Menu in Dreamweaver CS3 Using Spry R. Berdan

SSL Installing your new Certificate

How to FTP (How to upload files on a web-server)

Web Design Basics. Cindy Royal, Ph.D. Associate Professor Texas State University

Tutorial: setting up a web application

What is a Web Browser? Web Site Functionality. A client program that uses HTTP to communicate with web servers.

Livezilla How to Install on Shared Hosting By: Jon Manning

CS134 Web Site Design & Development. Quiz1

Configuring for SFTP March 2013

STATIC IP SET UP GUIDE VERIZON 7500 WIRELESS ROUTER/MODEM

INTRODUCTION TO WEB TECHNOLOGY

Microsoft Expression Web

Creating Web Pages with Dreamweaver CS 6 and CSS

Creating Java EE Applications and Servlets with IntelliJ IDEA

Adobe Dreamweaver - Basic Web Page Tutorial

Dreamweaver CS4 Day 2 Creating a Website using Div Tags, CSS, and Templates

Transcription:

Chapter 1 Introduction to web development and PHP Murach's PHP and MySQL, C1 2010, Mike Murach & Associates, Inc. Slide 1

Objectives Applied 1. Use the XAMPP control panel to start or stop Apache or MySQL when it is running on your own computer. 2. Deploy a PHP application on your own computer. 3. Run a web application that s on your own computer (1) by entering its URL into the address bar of a browser or (2) by getting and using an index of the applications that are on the web server. 4. View the source code for a web page in a web browser. Murach's PHP and MySQL, C1 2010, Mike Murach & Associates, Inc. Slide 2

Objectives (continued) Knowledge 1. Describe the components of a client-server architecture. 2. Describe HTTP requests and responses. 3. Distinguish between the way a web server processes static web pages and dynamic web pages. 4. Explain what these software components do as a web application runs: Apache, PHP, Firefox, and MySQL. 5. Describe the way a PHP application is deployed on your own computer or on an Internet server. 6. Describe the components of an HTTP URL. 7. Describe what happens if you omit one or more parts of a URL when you try to run an application or if you code a URL that specifies a directory that doesn t contain a default page. 8. Describe the benefits of using an IDE like NetBeans for application development. Murach's PHP and MySQL, C1 2010, Mike Murach & Associates, Inc. Slide 3

The architecture of a web application Client The Internet Web Server Database Server Client E-mail Server Murach's PHP and MySQL, C1 2010, Mike Murach & Associates, Inc. Slide 4

The architecture of the Internet LAN LAN LAN LAN LAN WAN IXP WAN LAN LAN WAN IXP IXP WAN LAN LAN LAN LAN LAN Murach's PHP and MySQL, C1 2010, Mike Murach & Associates, Inc. Slide 5

Key terms server client network router Local Area Network (LAN) Wide Area Network (WAN) Internet Internet Exchange Point (IXP) Internet Service Provider (ISP) Murach's PHP and MySQL, C1 2010, Mike Murach & Associates, Inc. Slide 6

How static web pages are processed HTTP request HTTP response HTML file Web Browser A simple HTTP request GET / HTTP/1.1 Host: www.example.com Web Server A simple HTTP response HTTP/1.1 200 OK Content-Type: text/html Content-Length: 136 Server: Apache/2.2.3 <html> <head> <title>example Web Page</title> </head> <body> <p>this is a sample web page</p> </body> Murach's PHP and MySQL, C1 2010, Mike Murach & Associates, Inc. Slide 7 </html>

How dynamic web pages are processed with PHP HTTP request HTTP response Web Browser Web Server Database Server PHP Script For a php page, the web server forwards the request to the php interpreter which is running on the web server. The php interpreter executes the script along with any form data and generates a web page which is returned to the browser. Murach's PHP and MySQL, C1 2010, Mike Murach & Associates, Inc. Slide 8

The first page of an application (index.html) Murach's PHP and MySQL, C1 2010, Mike Murach & Associates, Inc. Slide 9

The second page (display_discount.php) Murach's PHP and MySQL, C1 2010, Mike Murach & Associates, Inc. Slide 10

The HTML file (index.html) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>product Discount Calculator</title> <link rel="stylesheet" type="text/css" href="main.css" /> </head> <body> <div id="content"> <h1>product Discount Calculator</h1> <form action="display_discount.php" method="post"> <div id="data"> <label>product Description:</label> <input type="text" name="product_description"/> <br /> Murach's PHP and MySQL, C1 2010, Mike Murach & Associates, Inc. Slide 11

The HTML file (index.html) (continued) </form> </div> </body> </html> <label>list Price:</label> <input type="text" name="list_price"/><br /> <label>discount Percent:</label> <input type="text" name="discount_percent"/>%<br /> </div> <div id="buttons"> <label> </label> <input type="submit" value="calculate Discount" /> <br /> </div> Murach's PHP and MySQL, C1 2010, Mike Murach & Associates, Inc. Slide 12

The CSS file (main.css) body { font-family: Arial, Helvetica, sans-serif; } #content { width: 450px; margin: 0 auto; padding: 0px 20px 20px; background: white; border: 2px solid navy; } h1 { color: navy; } label { width: 10em; padding-right: 1em; float: left; } Murach's PHP and MySQL, C1 2010, Mike Murach & Associates, Inc. Slide 13

The CSS file (main.css) (continued) #data input { float: left; width: 15em; margin-bottom:.5em; } #buttons input { float: left; margin-bottom:.5em; } br { clear: left; } Murach's PHP and MySQL, C1 2010, Mike Murach & Associates, Inc. Slide 14

The PHP file (display_discount.php) <?php // get the data from the form $product_description = $_POST['product_description']; $list_price = $_POST['list_price']; $discount_percent = $_POST['discount_percent']; // calculate the discount $discount = $list_price * $discount_percent *.01; $discount_price = $list_price - $discount;?> // apply formatting to the dollar and percent amounts $list_price_formatted = "$".number_format($list_price, 2); $discount_percent_formatted = $discount_percent."%"; $discount_formatted = "$".number_format($discount, 2); $discount_price_formatted = "$".number_format($discount_price, 2); Murach's PHP and MySQL, C1 2010, Mike Murach & Associates, Inc. Slide 15

The PHP file (display_discount.php) (continued) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional...> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>product Discount Calculator</title> <link rel="stylesheet" type="text/css" href="main.css"/> </head> <body> <div id="content"> <h1>product Discount Calculator</h1> <label>product Description:</label> <span><?php echo $product_description;?> </span><br /> <label>list Price:</label> <span><?php echo $list_price_formatted;?> </span><br /> Murach's PHP and MySQL, C1 2010, Mike Murach & Associates, Inc. Slide 16

The PHP file (display_discount.php) (continued) <label>standard Discount:</label> <span><?php echo $discount_percent_formatted;?> </span><br /> <label>discount Amount:</label> <span><?php echo $discount_formatted;?> </span><br /> <label>discount Price:</label> <span><?php echo $discount_price_formatted;?> </span><br /> </div> </body> </html> Murach's PHP and MySQL, C1 2010, Mike Murach & Associates, Inc. Slide 17

How to deploy an application on an Internet server Use an FTP (File Transfer Protocol) program (such as Filezilla, Secure Shell SSH, or WinSCP ) to upload the tested directories and files to the Apache web server. Our web server is webdev.cislabs.uncw.edu Files should be uploaded to your public_html file Permissions on this directory, subdirectories, and subfiles should be set at 755. The URL is http://webdev.cislabs.uncw.edu/~abc1234 Murach's PHP and MySQL, C1 2010, Mike Murach & Associates, Inc. Slide 18

The components of an HTTP URL http://www.murach.com/books/lists.htm protocol domain name path filename What happens if you omit parts of a URL If you omit the protocol, the default of http:// will be used. If you omit the filename, one of the default filenames for the Apache web server will be used: index.htm, index.html, or index.php. If you omit the filename and there is no default file, Apache will display an index of the files and directories in the path. Murach's PHP and MySQL, C1 2010, Mike Murach & Associates, Inc. Slide 19

URLs for pages on an Internet web server A request for a specific page http://www.murach.com/books/xhcss.htm A request for the default (home) page of a web site http://www.murach.com/ URLs for applications on a local web server A request for the default page in an application directory http://localhost/book_apps/ch01_product_discount/ A request for a directory with no default page http://localhost/book_apps/ Murach's PHP and MySQL, C1 2010, Mike Murach & Associates, Inc. Slide 20

The source code for a PHP page Murach's PHP and MySQL, C1 2010, Mike Murach & Associates, Inc. Slide 21

How to view the source code for a page in Firefox Use the View Page Source command. How to view the source code for a page in IE Use the View Source command. Murach's PHP and MySQL, C1 2010, Mike Murach & Associates, Inc. Slide 22

NetBeans with three files in the main project open Murach's PHP and MySQL, C1 2010, Mike Murach & Associates, Inc. Slide 23

How to work with NetBeans projects To open a project, use the Open Project button in the toolbar. To start a new project, use the New Project button in the toolbar. To close a project, right-click on the project in the Projects tab and select the Close command from the resulting menu. To set the main project, right-click on the project in the Projects tab and select the Set As Main Project command from the resulting menu. How to work with NetBeans files To open a file, use the Projects tab to navigate to the file and double-click the file. To start a new file, select the project and click the New File button in the toolbar. Murach's PHP and MySQL, C1 2010, Mike Murach & Associates, Inc. Slide 24

About NetBeans NetBeans is an Integrated Development Environment (IDE) for developing PHP applications. NetBeans can make it easier to create, edit, and test the HTML, CSS, and PHP files that you need for a web application. About NetBeans projects A NetBeans project consists of a top-level directory that contains the subdirectories and files for an application. When you create a NetBeans project, NetBeans adds an nbproject subdirectory that contains the extra files that NetBeans needs for managing the project. Mac OS X note To enable right-clicking with Mac OS X, you can edit the system preferences for the mouse. Murach's PHP and MySQL, C1 2010, Mike Murach & Associates, Inc. Slide 25

Auto-completion and error marking in NetBeans Murach's PHP and MySQL, C1 2010, Mike Murach & Associates, Inc. Slide 26

How to edit a PHP file with NetBeans Use normal editing techniques as you enter PHP code. When you see an auto-completion list, you can highlight an entry and press the Enter key to enter it into your code or you can double-click on it. If you see a red error icon at the start of a line that you have entered, you should fix whatever errors the line contains before you test the application. How to test a PHP application with NetBeans To run the main project, click on the Run Project button in the toolbar or press F6. To run other projects, right-click on the project and select the Run command. To run a file, right-click on the file and select the Run command. Murach's PHP and MySQL, C1 2010, Mike Murach & Associates, Inc. Slide 27

The dialog box for starting a new project Murach's PHP and MySQL, C1 2010, Mike Murach & Associates, Inc. Slide 28

The dialog box for configuring a project Murach's PHP and MySQL, C1 2010, Mike Murach & Associates, Inc. Slide 29

How to check the run configuration for a project Right-click on a project in the Projects tab and select the Properties command. Then, click on Run Configuration in the Categories list and check the Project URL. How to import a project Use the New Project command, but select PHP Application with Existing Sources in the Projects list. This will step you through the import procedure. In the third step, you are asked to check the run configuration. Here, you need to make sure the URL for running the project is correct. Murach's PHP and MySQL, C1 2010, Mike Murach & Associates, Inc. Slide 30

Key terms HyperText Markup Language (HTML) static web page HTTP request HTTP response. dynamic web page PHP interpreter database server render round trip Murach's PHP and MySQL, C1 2010, Mike Murach & Associates, Inc. Slide 31