PHP on a Fast Track and other web development techniques a quick introduction to web programming by Jarek Francik.

Slides:



Advertisements
Similar presentations
PRACTICAL PHP AND MYSQL WALKTHROUGH USING SAMPLE CODES – MAX NG.
Advertisements

1 Web Servers / Deployment Alastair Dawes Original by Bhupinder Reehal.
Languages for Dynamic Web Documents
Server-Side vs. Client-Side Scripting Languages
Creating WordPress Websites. Creating a site on your computer Local server Local WordPress installation Setting Up Dreamweaver.
Dynamic Web Pages. Web Programming  All our web pages so far have been static pages. 1. We create a web page 2. We upload it to the web server 3. People.
Website Development with PHP and MySQL Introduction.
How Clients and Servers Work Together. Objectives Learn about the interaction of clients and servers Explore the features and functions of Web servers.
Computer Science 101 Web Access to Databases Overview of Web Access to Databases.
JOIN A COMMUNITY OF 80,000 E-COMMERCE SITES WORLDWIDE.
Dynamic Web site With PHP and MySQL. MySQL The combination of MySQL database and PHP scripting language is optimum for building dynamic websites. MySQL.
1 CS428 Web Engineering Lecture 18 Introduction (PHP - I)
ECA 228 Internet/Intranet Design I Intro to the Web.
Part or all of this lesson was adapted from the University of Washington’s “Web Design & Development I” Course materials.
Web Programming Language Dr. Ken Cosh Week 1 (Introduction)
PHP on a Fast Track a quick introduction to PHP programming by Jarek Francik.
SYST Web Technologies SYST Web Technologies Installing a Web Server (XAMPP)
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
E-Commerce LAB#1 Samia alblwi1E-Commerce ( IS412) 2011.
SJSU CS157B Dr. Lee1  2004 Jenny Mitchell Two Useful Tools You Can’t Live Without by Jenny Mitchell SJSU CS157B Section PHP and MySQL.
Lecture 3 – Data Storage with XML+AJAX and MySQL+socket.io
Advanced Web 2012 Lecture 4 Sean Costain PHP Sean Costain 2012 What is PHP? PHP is a widely-used general-purpose scripting language that is especially.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Technology Options. Entire Project – Technologies (over simplified) 1.Front-end 2.Database 3.Server-side scripting (front-end and database integration)
1 Chapter 8 – Working with Databases spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science and Technology.
INTERNET APPLICATION DEVELOPMENT For More visit:
Chapter 1: Introduction to Web
Server-side Scripting Powering the webs favourite services.
Lecture 14 – Web Security SFDV3011 – Advanced Web Development 1.
Tutorial 10 Adding Spry Elements and Database Functionality Dreamweaver CS3 Tutorial 101.
NMED 3850 A Advanced Online Design January 26, 2010 V. Mahadevan.
 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.
CS453: State in Web Applications (Part 1) State in General Sessions (esp. in PHP) Prof. Tom Horton.
SQL Queries Relational database and SQL MySQL LAMP SQL queries A MySQL Tutorial and applications Database Building Assignment.
Website Design Lecture 1. Outline Introduction to the module Outline of the Assessment Schedule Lecture Static XHTML, client side and server side Why.
JavaScript – Quiz #9 Lecture Code:
PHP MySQL Introduction. MySQL is the most popular open-source database system. What is MySQL? MySQL is a database. The data in MySQL is stored in database.
School of Computing and Information Systems CS 371 Web Application Programming PHP – Forms, Cookies, Sessions and Database.
NMED 3850 A Advanced Online Design January 12, 2010 V. Mahadevan.
SYST Web Technologies SYST Web Technologies Databases & MySQL.
Chapter 8 Collecting Data with Forms. Chapter 8 Lessons Introduction 1.Plan and create a form 2.Edit and format a form 3.Work with form objects 4.Test.
Kingdom of Saudi Arabia Ministry of Higher Education Al-Imam Muhammad Ibn Saud Islamic University College of Computer and Information Sciences Chapter.
1 Welcome to CSC 301 Web Programming Charles Frank.
Web Programming Brian Toone 8/27/2014. Outline for today 1.Understanding the architecture of the web 2.Overview of programming languages – Client-side.
PHP on a Fast Track a quick introduction to PHP programming by Jarek Francik last time updated in 2012.
Controlling Web Site Access Using Logins CS 320. Basic Approach HTML form a php page that collects the username and password  Sends them to second PHP.
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.
Unit 1 – Web Concepts Instructor: Brent Presley.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 2: Introduction to IS2803 Rob Gleasure
(ITI310) By Eng. BASSEM ALSAID SESSIONS 10: Internet Information Services (IIS)
PHP Form Processing * referenced from
Intro to APACHE, MySQL, and PHP & freely available (hackable) Packages Aonghus Sugrue 04 Oct 2012.
Web Page Designing With Dreamweaver MX\Session 1\1 of 9 Session 1 Introduction to PHP Hypertext Preprocessor - PHP.
ASP.NET WEB Applications. ASP.NET  Web application framework developed by Microsoft  Build dynamic data driven web applications and web services  Subset.
Installing a Moodle Test Site The painless and easy way.
ITX2000 Remote hosts and web servers Prof. Xiaohong (Sharon) Gao Room: T125 Ext: Week 8 – Review Reference:
COM621: Advanced Interactive Web Development Lecture 10 PHP and MySQL.
Web Programming Language
Tonga Institute of Higher Education IT 141: Information Systems
Introduction and Principles
Introduction to PHP FdSc Module 109 Server side scripting and
Introduction to Web programming
PHP / MySQL Introduction
Intro to PHP & Variables
Tonga Institute of Higher Education IT 141: Information Systems
Web Servers / Deployment
Tonga Institute of Higher Education IT 141: Information Systems
PHP By Prof. B.A.Khivsara Note: The material to prepare this presentation has been taken from internet and are generated only for students reference and.
Web Application Development Using PHP
Presentation transcript:

PHP on a Fast Track and other web development techniques a quick introduction to web programming by Jarek Francik

Teaching Objectives To ensure everyone of you have at least basic understanding of server-side processing To introduce some basic PHP To demonstrate what makes a good web project (and what doesn’t)

What is a project? A project is a temporary endeavour undertaken to create a unique product or service

A project is... a defined, unique venture or undertaking, that requires the effort or activities of people who have defined roles and responsibilities within a finite life-span, time-scale or schedule using specified resources and budgets, and has specific goals or objectives to achieve to which measures of quality can be applied that brings about some change in the status quo to provide sustainable benefit to some business, organisational or individual need

Project Snettisham

Research: 50,000 birds swirling like smoke clouds Oystercatchers, godwits, knots... Snettisham RSPB Reserve in Norfolk Best time: autumn, when most birds migrate LOOK FOR MORE INFORMATION!

Project Snettisham Research (cont.): The flocks take to the air as the high tide races in, covering their feeding grounds. They sit out high tide and return once the tide falls Spectaculars happen only in the mornings The higher the tide the better chances to see it!

Project Snettisham Need a really high tide early in the morning... UK Tides (Apple Store) USE PROPER TOOLS!

Project Snettisham Need a really high tide early in the morning... UK Tides (Apple Store) Timetables ready on the RSPB site! USE VARIOUS SOURCES OF INFORMATION

Project Snettisham Need a really high tide early in the morning... UK Tides (Apple Store) Timetables ready on the RSPB site! Three days trip Nov (to also see the Pink Footed Geese!) PLANNING IS CRUCIAL

Project Snettisham Need a really high tide early in the morning... UK Tides (Apple Store) Timetables ready on the RSPB site! Three days trip Nov (to also see the Pink Footed Geese!) Accommodation! PLANNING IS CRUCIAL

Project Snettisham Need a really high tide early in the morning... UK Tides (Apple Store) Timetables ready on the RSPB site! Three days trip Nov to see the Pink Footed Geese as well! Accomodation! Transport... Anything else... PLANNING IS CRUCIAL

What is a project? A project is a temporary endeavour undertaken to create a unique product or service Snettisham Trip is a project A trip to Winkworth Arboretum last Saturday wasn’t a project why?

What is a project? A project is a temporary endeavour undertaken to create a unique product or service A bespoke e-commerce solution for a company who need it is a project A novel HCI solution is a project A routine PC maintenance is not a project why?

What is a project? A project is a temporary endeavour undertaken to create a unique product or service A typical on-line store for a small company... hardly is a good project why?

PHP on a Fast Track

Client & Server ClientServer

Client & Server ClientServer

Client & Server ClientServer Remote File System

Client & Server ClientServer REQUEST: GET RESPONSE: HTML Remote File System

Client & Server CLIENT SIDE PROCESSING ClientServer REQUEST: GET RESPONSE: HTML Files served over the network may contain HTML, CSS, JavaScript, Flash and may be pretty much complex! Remote File System

Client & Server ClientServer REQUEST: GET RESPONSE: HTML Remote File System

Client & Server ClientServer REQUEST: GET RESPONSE: HTML Remote File System REQUEST: GET RESPONSE: HTML

Client & Server ClientServer REQUEST: POST RESPONSE: HTML Remote File System RESPONSE: HTML REQUEST: POST DB

Client & Server ClientServer REQUEST: POST RESPONSE: PHP Remote File System REQUEST: POST RESPONSE: PHP DB SERVER SIDE PROCESSING Great Hiking Shoe Perfect Company

Client-Side ProcessingServer-Side Processing DB

Client-Side Processing Executed locally, on client’s computer Results visible immediately Fast & dynamic Processing within a single webpage Information cannot be shared No Databases* Keeping things secret is very difficult – everything is on the user’s computer * Limited local database functionality is available in HTML5, but without sharing Server-Side Processing Executed remotely, on a web server Results must be sent over the network Network latency Pages must be re-loaded in order to view the results* Information easily shared Database back-end Flexible and powerful security control * AJAX technology allows for remote updates without pages being reloaded but technically it is a combination of server side and client side technologies

PHP Scripting language for web development Created by Rasmus Lerdorf 16 years ago Currently phasing out Easy to learn but time-consuming to use

Let’s write a shopping cart application

What do we need? Operating System Web Server Database Scripring Language Windows, Linux, MacOS... Appache, IIS, WEBrick... MySQL, Postgres, SQLite, Oracle... PHP, Perl, Python, Ruby, C#, Java... DB

What do we need? Operating System Web Server Database Scripring Language Windows, Linux, MacOS... Appache, IIS, WEBrick... MySQL, Postgres, SQLite, Oracle... PHP, Perl, Python, Ruby, C#, Java... DB

What do we need? Operating System Web Server Database Scripring Language Linux, Windows, MacOS... Appache, IIS, WEBrick... MySQL, Postgres, SQLite, Oracle... PHP, Perl, Python, Ruby, C#, Java... DB

What do we need? Operating System Web Server Database Scripring Language MacOS, Windows, Linux... Appache, IIS, WEBrick... MySQL, Postgres, SQLite, Oracle... PHP, Perl, Python, Ruby, C#, Java... DB

What do we need? Operating System Web Server Database Scripring Language X - Platform Appache MySQL PHP Perl DB

What do we need? Operating System Web Server Database Scripring Language X A M P DB

XAMPP or google for “xampp”

XAMPP 1.Download and install – it’s easy 2.Run XAMPP Control Panel 3.Start Apache & MySql 4.Run in your browser: Click Explore and go to htdocs to browse your web files 6.Use MySql Admin to setup your database with mySqlAdmin

phpMyAdmin

KU Server There is a web server available for you at Find all details there (or check the end of this presentation)

Database structure (SQL) USE test; CREATE TABLE goods ( id int(6) unsigned NOT NULL auto_increment, item varchar(100) NOT NULL default '', price decimal(6,2) NOT NULL default '0.00', image varchar(100) NOT NULL default '', PRIMARY KEY (id) ); INSERT INTO goods VALUES (1, 'Soap', '4.99'); INSERT INTO goods VALUES (2, 'Strawberry Jam', '1.99'); INSERT INTO goods VALUES (3, 'Toothpaste', '2.49'); INSERT INTO goods VALUES (4, '8GB Memory Stick', '22.99');

The First PHP File <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " Your Cart Your Cart <?php ?> cart.php 0

The First PHP File <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " Your Cart Your Cart <?php echo "Hello, world!"; ?> cart.php

Another File: Front Page <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " Your Shop Your Shop Add item #1 to the cart Add item #2 to the cart Add item #3 to the cart Add item #4 to the cart Show your cart index.php 1

What the application should do

What the application should do <?php $action = $_GET['action']; $id = $_GET['id']; echo " DEBUG: Action to do is $action, and item id is $id. "; ?> cart.php 1

Make information persistent HTTP as a stateless protocol protocol with no memory of who you are Cookies Sessions Session variables $_SESSION['cart'] Name of the variable Collection of session variables

Make information persistent must appear in the first line (before DOCTYPE) cart.php

Make information persistent <?php $cart = $_SESSION['cart']; $action = $_GET['action']; $id = $_GET['id']; echo " DEBUG: Action to do is $action, and item id is $id. "; if ($action == 'add') { $cart = $cart. ",$id"; $_SESSION['cart'] = $cart; } echo " DEBUG: Cart is: $cart "; ?> must appear in the first line (before DOCTYPE) cart.php 2

Display Your Cart <?php $cart = $_SESSION['cart']; $action = $_GET['action']; $id = $_GET['id']; if ($action == 'add') { $cart = $cart. ",$id"; $_SESSION['cart'] = $cart; } $myitems = explode(',', $cart);// explode using comma as a separator if (count($myitems) <= 1) echo " Your cart is empty. "; else foreach ($myitems as $i) if ($i != '') { echo " Item id: $i "; } ?> cart.php 3

Connect to the Database <?php $hostname = 'localhost';// localhost is the URL of the server $username = 'root';// the username in this example is root $password = 'elvis';// put here your MySQL root password // connect to the database server $con = mysql_connect($hostname, $username, $password) or die ('Could not connect: '. mysql_error()); // display if connection failed mysql_select_db("test", $con); // choose the test database... cart.php

Connect to the Database <?php $hostname = 'localhost';// localhost is the URL of the server $username = 'root';// the username in this example is root $password = 'elvis';// put here your MySQL root password // connect to the database server $con = mysql_connect($hostname, $username, $password) or die ('Could not connect: '. mysql_error()); // display if connection failed mysql_select_db("test", $con); // choose the test database... Provide the proper username & password (the latter maybe ‘’) cart.php

Display Your Items.... foreach ($myitems as $i) if ($i != '') { $result = mysql_query("SELECT * FROM goods WHERE id = $i"); $row = mysql_fetch_array($result); $item = $row['item']; $price = $row['price']; echo " $item: £$price "; } ?> cart.php 4

Final Polishings cart.php: Better HTML formatting Total price of the cart calculated index.php: Connected to the database

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " Your title here --> Your Cart <?php $hostname = 'localhost'; // localhost is the URL of the server $username = 'root'; // the username in this example is root $password = 'elvis'; // put here your MySQL root password // connect to the database server $con = mysql_connect($hostname, $username, $password) or die ('Could not connect: '. mysql_error());// display if failed mysql_select_db("test", $con); // choose the test database $cart = $_SESSION['cart']; $action = $_GET['action']; $id = $_GET['id']; if ($action == 'add') { $cart = $cart. ",$id"; $_SESSION['cart'] = $cart; } $myitems = explode(',', $cart);// explode using comma as a separator if (count($myitems) <= 1) echo " Your cart is empty. "; else { echo " "; $total = 0; foreach ($myitems as $i) if ($i != '') { $result = mysql_query("SELECT * FROM goods WHERE id = $i"); $row = mysql_fetch_array($result); $item = $row['item']; $price = $row['price']; $total += $price; echo " $item £$price "; } echo " Total &pound ;$total "; echo " "; } ?> [ Home Page ] cart.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " <?php $hostname = 'localhost'; // localhost is the URL of the server $username = 'root'; // the username in this example is root $password = 'elvis'; // put here your MySQL root password // connect to the database server $con = mysql_connect($hostname, $username, $password) or die ('Could not connect: '. mysql_error()); // display if failed mysql_select_db("test", $con); // choose the test database ?> Your Shop --> Your Shop <?php $result = mysql_query("SELECT * FROM goods"); while ($row = mysql_fetch_array($result)) { $id = $row['id']; $item = $row['item']; $price = $row['price']; echo " "; echo " $item "; echo " £$price "; echo " add to cart "; echo " "; }; mysql_free_result($result); ?> Show your cart index.php

Other Possible Options PHP... ???

Other Possible Options PHP ASP.NET Java Python Perl Ruby on Rails So, which way to go?

The goal of this lecture is to show that PHP is rarely a good choice!

Online Store Created with Ruby on Rails watch at:

How to do a good web project? How to avoid a bad web project? PHP is still popular for some simple tasks There are some really powerful frameworks written in PHP – e.g. Magento (Open Source) PHP is now 17 years old! ( ) consider something newer!

How to do a good web project? How to avoid a bad web project? Writing a web app from scratch is anachronism! ?

How to do a good web project? How to avoid a bad web project? Writing a web app from scratch is anachronism! Research – use various sources of information Use proper, modern tools Planning is crucial Wherever possible, build on top of something other people did

How to do a good web project? How to avoid a bad web project? On-Line Store: a bespoke solution in PHP – from scratch a bespoke solution in Rails – from scratch, but with substantial support from the framework open source solution: Magento (as ) hosted solutions: Shopify, Volusion build something exciting on top of available systems

So what to choose? Your project should be based on what you learned during the course It doesn’t mean you must not learn anything new! Use your experience, do a research, READ, be brave! Try to do something unique

THE END

How to use studentnet

Your personal website is (provide your correct k-number) To upload files, you will need a FTP client program to send your files to the server. Here are configuration settings for Filezilla: – Host: studentnet.kingston.ac.uk – Protocol: SFTP – User: k (your normal k number) – Password: ******** (your normal password)

How to use studentnet To configure your database: go to Database Management Tool (link available at the main page login with your standard KU knumber and password). First time, you will be asked to configure the name of your database and the password – remember them! You will then be able to Manage Database. Use your KU k-number and the database password (you created it in the previous point). You will find yourself in phpMyAdmin. Use it to create faces table and populate it with data, exactly the same as we did it with XAMPP

How to use studentnet Before uploading your application you have to setup the connection for the new server – see the example below (do it for each PHP file that connects to the DB): $hostname = 'studentnet.kingston.ac.uk'; // URL of the server $username = ‘k '; // replace with your real username $password = ‘elvis'; // your MySQL database password should go here // connect to the database server $con = mysql_connect($hostname, $username, $password) or die ('Could not connect: '. mysql_error()); // display if connection failed mysql_select_db("db_k ", $con); // replace with your real db name