Web Programming Introduction to PHP COM427 1. Objectives To understand what PHP is and how a PHP script works with a Web Browser and a Web Server To learn.

Slides:



Advertisements
Similar presentations
Copyright © 2003 Pearson Education, Inc. Slide 1-1 The Web Wizards Guide to PHP by David A. Lash.
Advertisements

1 Copyright © 2002 Pearson Education, Inc.. 2 Chapter 1 Introduction to Perl and CGI.
PHP I.
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Java Script Session1 INTRODUCTION.
Introduction to PHP MIS 3501, Fall 2014 Jeremy Shafer
Building Applications using ASP.NET and C# / Session 1 / 1 of 21 Session 1.
Learning Web development. 3(+1) Tier architecture PHP script Remote services Web Server (Apache, IIS) Browser (IE, FireFox, Opera) Desktop (PC or MAC)
B.Sc. Multimedia ComputingMedia Technologies Database Technologies.
Introduction to PHP. PHP Origins Rasmus LerdorfRasmus Lerdorf (born Greenland, ed Canada) PHP originally abbreviation for ‘Personal Home Pages’, now ‘PHP.
Creating WordPress Websites. Creating a site on your computer Local server Local WordPress installation Setting Up Dreamweaver.
1 Web Wizards Guide To PHP David Lash Chapter 1 Introduction to PHP.
Introduction to PHP (Part-1) Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
Dynamic Web site With PHP and MySQL. MySQL The combination of MySQL database and PHP scripting language is optimum for building dynamic websites. MySQL.
2440: 141 Web Site Administration Web Server-Side Programming Professor: Enoch E. Damson.
1 CS428 Web Engineering Lecture 18 Introduction (PHP - I)
PHP By Dr. Syed Noman Hasany. PHP PHP was originally created by Rasmus Lerdorf in PHP stands for PHP: Hypertext Preprocessor (a recursive acronym).
8/17/2015CS346 PHP1 Module 1 Introduction to PHP.
Web Page A page displayed by the browser. Website Collection of multiple web pages Web Browser: A software that displays web pages on client computer.
PHP and MySQL Week#1  Course Plan.  Introduction to Dynamic Web Content.  Setting Up Development Server Eng. Mohamed Ahmed Black 1.
The PHP Story. PHP Story PHP is a programming language. Incorporate(join) sophisticated business logic. Widely used general purpose scripting language.
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
Sys Prog & Scripting - HW Univ1 Systems Programming & Scripting Lecture 15: PHP Introduction.
CSC 318 WEB APPLICATION DEVELOPMENT.  Introduction to Server Scripting language  Client VS Server  Introduction to PHP  PHP Files and Syntax  Function.
PHP HYPERTEXT: PREPROCESSOR By: Justin T. Pleva. WHAT IS PHP?  General purpose  Server-side web development  Console application.
INTRODUCTION TO WEB DATABASE PROGRAMMING
Server- Side technologies Client-side vs. Server-side scripts PHP basic ASP.NET basic ColdFusion.
AIT 616 Fall 2002 PHP. AIT 616 Fall 2002 PHP  Special scripting language used to dynamically generate web documents  Open source – Free!!!  Performs.
Copyright © 2003 Pearson Education, Inc. Slide 1-1 Web Design & Development PHP.
IDK0040 Võrgurakendused I harjutus 06: PHP: Introduction Deniss Kumlander.
INTERNET APPLICATION DEVELOPMENT For More visit:
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
10/5/2015CS346 PHP1 Module 1 Introduction to PHP.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 21 - Web Servers (IIS, PWS and Apache) Outline 21.1 Introduction 21.2 HTTP Request Types 21.3.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
November 2003Bent Thomsen - FIT 6-11 IT – som værktøj Bent Thomsen Institut for Datalogi Aalborg Universitet.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
1 Welcome to CSC 301 Web Programming Charles Frank.
Dynamic web content HTTP and HTML: Berners-Lee’s Basics.
Intro to PHP IST2101. Review: HTML & Tags 2IST210.
Introduction to PHP Advanced Database System Lab no.1.
Introduction to JavaScript CS101 Introduction to Computing.
Overview of Form and Javascript fundamentals. Brief matching exercise 1. This is the software that allows a user to access and view HTML documents 2.
PHP “Personal Home Page Hypertext Pre-processor” (a recursive acronym) Allows you to create dynamic web pages and link web pages to a database.
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
WHAT IS SERVER SIDE SCRIPTING? Server-side scripting is a web server technology in which a user's request is verified by running a script directly on the.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
 Web pages originally static  Page is delivered exactly as stored on server  Same information displayed for all users, from all contexts  Dynamic.
ASP-2-1 SERVER AND CLIENT SIDE SCRITPING Colorado Technical University IT420 Tim Peterson.
Unit 1 – Web Concepts Instructor: Brent Presley.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 2: Introduction to IS2803 Rob Gleasure
8 th Semester, Batch 2009 Department Of Computer Science SSUET.
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
Web Page Designing With Dreamweaver MX\Session 1\1 of 9 Session 1 Introduction to PHP Hypertext Preprocessor - PHP.
PHP stands for …….. “PHP Hypertext Pre-processor” and is a server-side scripting language like ASP. PHP scripts are executed on the server PHP supports.
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 Basics and Syntax Lesson 3 ITBS2203 E-Commerce for IT.
Introduction and Principles
* Lecture # 7 Instructor: Rida Noor Department of Computer Science
Introduction to Programming the WWW I
PHP / MySQL Introduction
BASIC PHP and MYSQL Edward S. Flores.
PHP Introduction.
Intro to PHP & Variables
Module 1 Introduction to PHP 11/30/2018 CS346 PHP.
PHP and Forms.
Introduction to PHP.
The Web Wizard’s Guide to PHP by David A. Lash
Presentation transcript:

Web Programming Introduction to PHP COM427 1

Objectives To understand what PHP is and how a PHP script works with a Web Browser and a Web Server To learn what software and components you need to get started with PHP To create and run a simple PHP script COM427 2

Web servers Can be considered at two levels: 1.The physical computer that stores web files and web application programs. 2.More precisely, the web server is a specialized piece of software, running on the server computer, which receives requests, via the Internet, for web pages or programs retrieves the pages / executes the programs returns the results over the Internet to the browser. Common web servers: – Apache – Microsoft Internet Information Services (IIS) COM427 3

Web Application Program Carries out many dynamic tasks, such as the following: – Input a search term, search the WWW, and return the results – Calculate and display the number of times that a page has been viewed – Verify the input fields on a Web form – Save a Web form into a database – Display a special graph, or return the results of a calculation based on data input from a form COM427 4

What is PHP? Original of PHP (Rasmus Lerdorf) [born in Qeqertarsuaq, Greenland] Server side – e.g. form handling, database access – (as opposed to Javascript which is mainly clientside) (X)HTML-embedded scripting language COM427 5

Basic Browser Web Server interaction 6 1. Browser in Client sents http request e.g Server receives request and activates php to interpret php program (test.php) 3. Server sends html output to browser in client for display

PHP Advantages Advantages of Using PHP to enhance Web pages: – Easy to use. – Open source. – Multiple platform. COM427 7

Browser PHP MySQL Interaction 8 A third layer can be added if php makes a call to a database to supply data in response to web browser request

Browser/PHP/database example 9 Browser holds html form Enter Details of Car Reg Num Make Submit PHP program - Receives values - Plugs them into database query - Sends Request to database - Receives data and - Returns result as web page Details of Car Taxed ? Yes MOT? Yes Reg Date: 1 st Jan Car Database

PHP & Javascript Javascript – Client side – Good for form validation – Good for web page presentation – Poor for security – Some database access PHP – Server side – Better security – Good database access COM42710

Getting Started with PHP To develop and publish PHP scripts all you need is: – A Web server with PHP built into it – A client machine with a basic text editor and Internet connection – FTP software (if webserver used)  Use localhost in the development phase and then upload to the server COM427 11

Installation of Apache, PHP and MySQL In the lab: Apache server, PHP, MySQL installed At home: – Install Apache, PHP and MySQL separately, – Or install Apache, PHP, MySQL together using a package, eg. WAMP or MAMP (for Windows or Mac) – XAMPP installs very easily & is cross-platform (Windows or Mac) COM427 12

Install Apache, PHP & MySQL Download XAMPP Installs Apache/PHP/MySQL (plus PERL) Cross platform (Mac/Windows/Linux) COM427 13

Using Apache, PHP and MySQL iMAC Lab – Save your HTML file (e.g. test.html) or PHP file (e.g. myprog.php) under: Macintosh ID/Users/Labuser/Sites – Run html or php file under Apache using: e.g. OR create subdirectory starting with b (e.g. student number b00XXXXXX ) Click on file in browser window Windows Lab/ Own Windows Machine [ Put files in C://xampp/htdocs e.g. hello.php URL to run file OR create subdirectory and click on browser list] COM427 14

Using MySQL – MAC Lab Login (MySQL) Login: labuser Password: macimd15 Windows Lab login (MySQL) Login: labuser Password: Labuser1 COM42715

Creating a PHP Script File You can use a number of different editors to create your PHP script files. TextWrangler (can add line numbers) Save file with.php extension [In Windows Lab can use Notepad++ to create PHP scripts] COM427 16

Working with HTML Use tags <?php // opening php tag ?>// closing php tag Save the file with.php extension COM427 17

Accessing Your File Using a Browser COM You should use this URL in the iMac LAB: for html files: for php files:

Print Statement Syntax The print statement syntax: COM427 19

Echo Statement Syntax The echo statement syntax: echo "the message to print"; Echo almost identical to print COM427 20

If Use Improper Syntax Suppose you use the wrong syntax: 1. <?php 2. print "A simple initial script; 3. ?> COM Missing inverted commas

A Little About PHP's Syntax Some PHP Syntax Issues: – Be careful to use quotation marks, parentheses, and brackets in pairs. – Most PHP commands end with a semicolon (;). – Be careful of case. – PHP ignores blank spaces. COM427 22

Embedding PHP Statements Within HTML Documents One way to use PHP is to embed PHP scripts within HTML tags in an HTML document. (prog1.php) HTML With PHP Embedded Welcome To My Page 6.<?php 7. print " Using PHP gets easier as you keep practising it "; 8.?> 9. (PHP code alone will run fine since system will construct an html output for browser automatically) COM427 23

Using Backslash (\) to Generate HTML Tags with print() Sometimes you want to output an HTML tag that also requires double quotation marks. – Use the backslash ("\") character to signal that the double quotation marks themselves should be output: print " "; – The above statement would output: COM427 24

Using Comments with PHP Scripts Comments enable you to include descriptive text along with the PHP script. – Comment lines are ignored when the script runs; they do not slow down the run-time. – Comments have two common uses. Describe the overall script purpose. Describe particularly tricky script lines. COM427 25

Using Comments with PHP Scripts Comment Syntax - Use // <?php // This is a comment ?> Can place on Same line as a statement: <?php print "A simple initial script"; //Output a line ?> COM427 26

Example Script with Comments (prog2.php) Generating HTML From PHP 3. Generating HTML From PHP 4. <?php 5. // 6. // Example script to output HTML tags 7. // 8. print "Using PHP has some advantages: "; 9. print " Speed Ease of Use Functionality "; //Output bullet list 10. print " "; 11. ?> COM427 27

Alternative Comment Syntax PHP allows a couple of additional ways to create comments. <?php phpinfo(); # This is a built-in function ?> Multiple line comments. <?php /* A script that gets information about the PHP version being used. */ phpinfo(); ?> COM427 28

Summary You can embed a PHP script within an HTML document or run it as a stand-alone script. To begin working with PHP you need a Web server with built-in PHP, a client machine with a basic text editor PHP script process: write the PHP script, copy its file to the Web server, and access the file with a Web browser. Comments can be preceded by two forward slashes (//). COM427 29

Contents to be covered (Wk 1-8) Variables, Operations and Expressions Control statements – if statements – for & while loops Arrays – 1-dimensional – 2-dimensional (tables) Functions Form handling File handling COM427 30

Resources COM427 31