Website Development Introducing PHP The PHP scripting language Syntax derives from C, Java and Perl Open Source Links to MySql database.

Slides:



Advertisements
Similar presentations
PHP Form and File Handling
Advertisements

PHP I.
MWD1001 Website Production Using JavaScript with Forms.
Session 1 & 2BBK P1 Module5-May-2007 : [‹#›] PHP: The Basics.
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
1 Database Driven Web Application Clients Application Servers including web servers Database Server Traditional client-server (2-tier architecture): client:
Website Development Registering Users – Introducing Cookies.
IST 221 Internet Concepts and Applications Introduction to PHP.
Guide To UNIX Using Linux Third Edition
PHP Server-side Programming. PHP  PHP stands for PHP: Hypertext Preprocessor  PHP is interpreted  PHP code is embedded into HTML code  interpreter.
2012 •••••••••••••••••••••••••••••••••• Summer WorkShop Mostafa Badr
PHP Basics 1 ICS213, 1 / 2011 Dr. Seung Hwan Kang 1.
PHP: Introduction By Trevor Adams.
PHP Workshop ‹#› PHP: The Basics. PHP Workshop ‹#› What is it? PHP is a scripting language commonly used on web servers. –Stands for “PHP: Hypertext Preprocessor”
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
Server Side Scripting Norman White. Where do we do processing? Client side – Javascript (embed code in html) – Java applets (send java program to run.
PHP: Hypertext Processor Fred Durao
ALBERT WAVERING BOBBY SENG. Week Whatever: PHP  Announcements/questions/complaints.
04/09/20151 PHP & MySQL 'Slide materials are based on W3Schools PHP tutorial, 'PHP website 'MySQL website.
PHP Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
Application Development Description and exemplification of server-side scripting language for server connection, database selection, execution of SQL queries.
CP3024 Lecture 3 Server Side Facilities. Lecture contents  Server side includes  Common gateway interface (CGI)  PHP Hypertext Preprocessor (PHP) pages.
INTERNET APPLICATION DEVELOPMENT For More visit:
2010/11 : [1]Building Web Applications using MySQL and PHP (W1)PHP Recap.
PHP H ypertext P re-processor. Unit 6 - PHP - Hello World! - Data types - Control structures - Operators.
INTERNET APPLICATION DEVELOPMENT For More visit:
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
NMED 3850 A Advanced Online Design January 26, 2010 V. Mahadevan.
School of Computing and Information Systems CS 371 Web Application Programming PHP - Basics Serving up web pages.
A little PHP. Enter the simple HTML code seen below.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
CMPS 211 JavaScript Topic 1 JavaScript Syntax. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction.
November 2003Bent Thomsen - FIT 6-11 IT – som værktøj Bent Thomsen Institut for Datalogi Aalborg Universitet.
PHP - Basic Language Constructs CSCI 297 Scripting Languages - Day Two.
Website Development with PHP and MySQL Saving Data.
1 © Netskills Quality Internet Training, University of Newcastle HTML Forms © Netskills, Quality Internet Training, University of Newcastle Netskills is.
PHP2. PHP Form Handling The PHP $_GET and $_POST variables are used to retrieve information from forms, like user input. Name: Age:
PHP Programming with MySQL Slide 4-1 CHAPTER 4 Functions and Control Structures.
Overview: 1. Discussion of the basic architecture of a web application. 2. Discussion of the relevance of using MySQL and PHP in a web application.
CSC 2720 Building Web Applications Server-side Scripting with PHP.
PHP. What is PHP? PHP stands for PHP: Hypertext Preprocessor PHP is a server-side scripting language, like ASP PHP scripts are executed on the server.
PHP Arūnas Liuiza. PHP 101 What is PHP? Widely popular dynamic interpreted opensource programming language, aimed for web development Syntax is simmilar.
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.
Server-Side Scripting with PHP ISYS 475. PHP Manual Website
Introduction to PHP.
IT ELECTIVE 2.  Web server Can refer to either the hardware (the computer) or the software (the computer application) that helps to deliver content that.
 2001 Prentice Hall, Inc. All rights reserved. Chapter 7 - Introduction to Common Gateway Interface (CGI) Outline 7.1Introduction 7.2A Simple HTTP Transaction.
OperatorstMyn1 Operators An operator is something that you feed with one or more values (or expressions, in programming jargon) which yields another value.
8 th Semester, Batch 2009 Department Of Computer Science SSUET.
1 PHP Intro PHP Introduction After this lecture, you should be able to: Know the fundamental concepts of Web Scripting Languages in general, PHP in particular.
Learning PHP: Programming Review. PHP is one of many programming languages Different languages have their advantages and disadvantages and are therefore.
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,
11 – Introduction to PHP(1) Informatics Department Parahyangan Catholic University.
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
CGS 3066: Web Programming and Design Spring 2016 PHP.
PHP WORKSHOP (Session 1) INFO 257 Supplement. Outline What is PHP ? PHP Language Basics PHP Exercise.
A little PHP. Enter the simple HTML code seen below.
PHP using MySQL Database for Web Development (part II)
A little PHP.
CHAPTER 5 SERVER SIDE SCRIPTING
DBW - PHP DBW2017.
PHP Introduction.
Intro to PHP & Variables
More Selections BIS1523 – Lecture 9.
PHP.
HYPERTEXT PREPROCESSOR BY : UMA KAKKAR
Web Programming Language
PHP: Hypertext Preprocessor
PHP an introduction.
Presentation transcript:

Website Development Introducing PHP

The PHP scripting language Syntax derives from C, Java and Perl Open Source Links to MySql database

How PHP is written PHP is mixed with html PHP is kept between start and end tags The PHP interpreter, picks out the PHP code in the HTML It then interprets the code It then produces HTML This looks very messy The ideas are very simple though It is easier than CGI languages like Perl that have to write out the HTML

: Customer browser request service access page interpret set data present html return html get data databasescripting language web server How server side scripting works

First PHP instruction echo(“Mary had a little lamb”); Mary had a little lamb gets converted to you end statements with a semi-colon

Embedding in HTML ;... Code is placed between start and end tags:

; echo("or this"); Test

you can escape into php like this, or simply like this, or this Results in the following HTML:

Variables Start with a $ Then a letter or underscore Then any number of letters, underscores or numbers Examples $customer $_1_of_the_many $go2work

PHP supports the following types: array floating-point numbers integer object string

ExampleNameResult $a + $bAdditionSum of $a and $b. $a - $bSubtractionDifference of $a and $b. $a * $bMultiplicationProduct of $a and $b. $a / $bDivisionQuotient of $a and $b. $a % $bModulusRemainder of $a divided by $b. Table Arithmetic Operators

<?php $h = "Hello"; $w = "World"; echo($h); echo ($w); ?> Test

A useful property of strings Variables are expanded in strings $y = 2007; echo (“Year is $y”); echo (“Year is 2007”); is equivalent to

<?php $h = "Hello"; $w = "World"; $y = 2007; echo("This is another $h $w $y program"); ?> Test

A loop: for (exp1; exp2; exp3) statement; exp1 exp2 statement exp3 true false the statement can be a compound statement surrounded by { and }

<?php for ($i=1; $i<10; $i=$i+1) { echo("$i "); }; ?> Test

Auto-increment, auto-decrement $i++ $i-- add one to $i subtract one from $i

<?php for ($i=1; $i<15; $i++) { echo("$i "); }; ?> Test

Some clever stuff with loops You can include html in the loop statement for (exp1; exp2; exp3) { php code html code … };

A simple table HTML for creating a table

escape back to html Test

cell 1 cell 2 cell 3 cell 4 cell 5 Results in

Test

From here on I will introduce constructs as needed Look at the manual to find out more Links to the manual and other sources will be embedded in the slidesmanual Some useful references directly into the manual follow

Chapter 11. Control Structures if else elseif while do..while for foreach break continue switch

Table Comparison Operators ExampleNameResult $a == $bEqualTrue if $a is equal to $b. $a != $bNot equalTrue if $a is not equal to $b. $a < $bLess thanTrue if $a is strictly less than $b. $a > $bGreater thanTrue if $a is strictly greater than $b. $a <= $bLess than or equal to True if $a is less than or equal to $b. $a >= $bGreater than or equal to True if $a is greater than or equal to $b.

PHP Array Example Test

PHP Form Handling

What this example does The page above contains two input fields and a submit button. When the user fills in this form and clicks on the submit button, the form data is sent to the "welcome.php" file. The "welcome.php" file looks contains these lines: Test

PHP File Handling The fopen() function is used to open files in PHP. The first parameter of this function contains the name of the file to be opened and the second parameter specifies in which mode the file should be opened:

File Modes

Example The following example generates a message if the fopen() function is unable to open the specified file:

Reading a File Line by Line The example below reads a file line by line, until the end of file is reached: Test

Writing to the File So we could use the Post variable to write data entered via a form to a file. Then read it back line-by-line. Basis for a simple guestbook.

Summary PHP is a server side scripting language It is merged in with HTML The interpreter produces HTML It has a full range of variables and control structures We shall later look at functions and objects