Software Engineering for Internet Applications

Slides:



Advertisements
Similar presentations
PHP Hypertext Preprocessor Information Systems 337 Prof. Harry Plantinga.
Advertisements

PHP Intro/Overview Squirrel Book pages Server-side Scripting Everything you need to know in one slide 1.Web server (with PHP “plug-in”) gets a.
PHP Server-side Programming. PHP  PHP stands for PHP: Hypertext Preprocessor  PHP is interpreted  PHP code is embedded into HTML code  interpreter.
2440: 141 Web Site Administration Web Server-Side Programming Professor: Enoch E. Damson.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Introduction to PHP. PHP PHP is the Hypertext Pre-processor –Script language –Embedded into HTML –Runs as Apache module –Can use DB (MySQL, Oracle, Microsoft.
Application Development Description and exemplification of server-side scripting language for server connection, database selection, execution of SQL queries.
PHP - Hypertext Preprocessor. Introduction PHP is a powerful server-side scripting language for creating dynamic and interactive websites. PHP is a powerful.
SCV1223 PHP - Hypertext Preprocessor. Introduction PHP is a powerful server-side scripting language for creating dynamic and interactive websites. PHP.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Cookies & Sessions.
MySQL in PHP – Page 1 of 17CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: MySQL in PHP Reading: Williams &
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.
Elements of ASP Documents Adapted from MCDN Web Workshop ( and Webmonkey’s Introduction to Active.
Week 9 PHP Cookies and Session Introduction to JavaScript.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
School of Computing and Information Systems CS 371 Web Application Programming PHP – Forms, Cookies, Sessions and Database.
Lecture 10 – MYSQL and PHP (Part 2)
Open Source Software Unit – 3 Presented By Mr. R.Aravindhan.
Introduction to CS520/CS596_026 Lecture Two Gordon Tian Fall 2015.
CS320 Web and Internet Programming Introduction to PHP Chengyu Sun California State University, Los Angeles.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP & MySQL.
Server-Side Scripting with PHP ISYS 475. PHP Manual Website
Creating Databases for Web applications Server side vs client side PHP basics Homework: Get your own versions of sending working: both html and Flash!
SESSIONS 27/2/12 Lecture 8. ? Operator Similar to the if statement but returns a value derived from one of two expressions by a colon. Syntax: (expression)
1) PHP – Personal Home Page Scripting Language 2) JavaScript.
8 th Semester, Batch 2009 Department Of Computer Science SSUET.
1 PHP HTTP After this lecture, you should be able to know: How to create and process web forms with HTML and PHP. How to create and process web forms with.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14 Web Database Programming Using PHP.
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.
Unit-6 Handling Sessions and Cookies. Concept of Session Session values are store in server side not in user’s machine. A session is available as long.
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,
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
1 Server Side scripting PHP. 2 What is PHP? PHP stands for PHP: Hypertext Preprocessor PHP is a server-side scripting language, like ASP PHP scripts are.
Presented By Sushil K. Chaturvedi Assistant Professor SRCEM,Banmore 1.
A pache M ySQL P hp Robert Mudge Reference:
Mini – Workshop on PHP Faculty of Engineering in Foreign Languages 1.
PHP using MySQL Database for Web Development (part II)
Web Database Programming Using PHP
CGS 3066: Web Programming and Design Spring 2017
CHAPTER 5 SERVER SIDE SCRIPTING
PHP (Session 1) INFO 257 Supplement.
Introduction to Dynamic Web Programming
Chapter 5 Scripting Language
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Web Database Programming Using PHP
DBW - PHP DBW2017.
Web Technologies PHP 5 Basic Language.
19.10 Using Cookies A cookie is a piece of information that’s stored by a server in a text file on a client’s computer to maintain information about.
Chapter 19 PHP Part III Credits: Parts of the slides are based on slides created by textbook authors, P.J. Deitel and H. M. Deitel by Prentice Hall ©
PHP (PHP: Hypertext Preprocessor)
Topics to be Covered: Sending an , Multipart Message,
Chapter 5 Scripting Language
PHP / MySQL Introduction
PHP Introduction.
PHP and MySQL.
ISC440: Web Programming 2 Server-side Scripting PHP 3
<?php require("header.htm"); ?>
PHP.
Web DB Programming: PHP
HYPERTEXT PREPROCESSOR BY : UMA KAKKAR
Web Programming Language
Intro to PHP.
PHP State.
PHP: Hypertext Preprocessor
PHP an introduction.
PHP PROF. S. LAKSHMANAN, DEPT. OF B. VOC. (SD & SA),
PHP-II.
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.
[Based in part on SWE 432 and SWE 632 materials by Jeff Offutt, GMU]
Presentation transcript:

Software Engineering for Internet Applications PHP Hypertext Preprocessor ADF 11/28/2018

Types of Websites Static and Dynamic To create a dynamic one, web developers need web programming skill Server-side programming ASP, JSP, PHP Client-side programming HTML, JavaScript, VbScript 11/28/2018

PHP Hypertext Preprocessor Server-side programming language design especially for web application Programming language to create dynamic content to interacts with databases integrated with a number of popular databases, including MySQL, PostgreSQL, Oracle, Sybase, Informix, and Microsoft SQL Server 11/28/2018

PHP Components PHP Characteristics Web Server Database PHP Parser Whitespace insensitive Case sensitive 11/28/2018

PHP Script Tag comment <?php PHP code goes here ?> <script language="php"> PHP code goes here </script> /* comments */ // comment # comment 11/28/2018

PHP Variables PHP is untyped language. Datatype in PHP PHP variable can hold a value of any data type. The value type of a variable can change during the execution of a program and PHP takes care of it automatically Datatype in PHP Integer, double Strings Boolean Array Object 11/28/2018

PHP Variables Denoted with a leading dollar sign ($) The value of a variable is the value of its most recent assignment <?php $name = "Ali"; $age; $money = 2000.50; ?> 11/28/2018

PHP Flow Control <?php if (condition){ code to be executed if condition is true; }elseif (condition){ }else{ code to be executed if condition is false; } ?> <?php switch (expression) { case condition 1: statement(s) break; case condition 2: statement(s) reak; ... case condition n: statement(s) default: statement(s) } ?> 11/28/2018

PHP Loop <?php for (initialization; condition; increment){ code to be executed; } ?> <?php while (condition){ code to be executed; } ?> <?php do{ code to be executed; }while (condition); ?> <?php foreach (array as value){ code to be executed; } ?> 11/28/2018

PHP Arrays Numeric array Associative array Multidimensional array An array with a numeric index. Values are stored and accessed in linear fashion Associative array An array with strings as index. This stores element values in association with key values rather than in a strict linear index order. Multidimensional array 11/28/2018

PHP Arrays <?php $numbers = array( 1, 2, 3, 4, 5); ?> <?php $numbers[0] = "one"; $numbers[1] = "two"; $numbers[2] = "three"; $numbers[3] = "four"; $numbers[4] = "five"; ?> <?php foreach( $numbers as $value ){ echo "Value is $value <br />"; } ?> 11/28/2018

PHP Associative Arrays $student_id = array( "andi" => 0001, "budi" => 0002, "cita" => 0003 ); ?> <?php $student_id['andi'] = "IF01"; $student_id['budi'] = "IF02"; $student_id['cita'] = "IF03"; ?> <?php echo "ID andi: ". $student_id['andi'] . "<br />"; echo "ID budi: ". $student_id['budi']. "<br />"; echo "ID cita: ". $student_id['cita']. "<br />"; ?> 11/28/2018

PHP Multidimensional Arrays $marks = array( "andi" => array( "physics" => 70, "programming" => 80, "calculus" => 60 ), "budi" => array( "physics" => 78, "programming" => 88, "calculus" => 90 ), "cita" => array( "physics" => 67, "programming" => 88, "calculus" => 100 ) ); ?> <?php echo $marks['andi']['physics'] . "<br />"; echo $marks['budi']['programming'] . "<br />"; echo $marks['cita']['calculus'] . "<br />"; ?> 11/28/2018

Using HTML Forms <html> <body> <form action="<?php $_PHP_SELF ?>" method="POST"> Data 1: <input type="text" name="data1" /> Data 2: <input type="text" name="data2" /> <input type="submit" /> </form> </body> </html> <?php if( $_POST["data1"] || $_POST["data2"] ){ echo "Data 1 : ". $_POST['data1']. "<br />"; echo "Data 2 : ". $_POST['data2']; exit(); } ?> 11/28/2018

Form Passing $_GET $_POST $_REQUEST Retrieve parameters passed via URL (using GET method) into $_GET array $_POST Retrieve parameters passed via HTTP header (using POST method) into $_ POST array $_REQUEST contains the contents of both $_GET, $_POST, and $_COOKIE 11/28/2018

File Inclusion include( “file.php” ) require( “file.php” ) Takes all the text in a specified file and copies it into the file that uses the include function generates a warning if there is any problem, but the script will continue execution require( “file.php” ) Also takes all the text in a specified file and copies it into the file generates a fatal error and halt the execution of the script when a problem occurs 11/28/2018

PHP Function <?php /* Defining a PHP Function */ function HelloWorld() { echo "hello world"; } /* Calling a PHP Function */ HelloWorld(); ?> <?php function multiplyThis($num1, $num2){ $mult = $num1 * $num2; echo "$num1 multiply bu $num2 is $mult"; } multiplyThis(10, 20); ?> 11/28/2018

PHP Function <?php function incBy5($num){ $num += 5; } $input = 10; incBy5( $input ); echo "the result is $input <br />"; ?> <?php function multiplyThis($num1, $num2){ $mult = $num1 * $num2; return $mult; } $result = multiplyThis(10, 20); echo "Returned value from the function : $result"; ?> 11/28/2018

Cookies and Sessions Cookies Session text files stored on the client computer for tracking purpose. PHP transparently supports HTTP cookies. usually set in an HTTP header Session file in a temporary directory on the server This data will be available to all pages on the site during the visit 11/28/2018

PHP Cookies Setting cookies <?php Called before <html> tag Each cookies must be called separately <?php setcookie(name, value, expire, path, domain, security); ?> <?php setcookie("name", "Andi", time()+3600, "/","", 0); setcookie("age", "36", time()+3600, "/", "", 0); ?> <html> . . . 11/28/2018

PHP Cookies Accessing Cookies <body> <?php if( isset($_HTTP_COOKIE_VARS["name"])) echo "Welcome " . $_ HTTP_COOKIE_VARS["name"] . "<br />"; else echo "Sorry... Not recognized" . "<br />"; ?> </body> <body> <?php if( isset($_COOKIE["name"])) echo "Welcome " . $_COOKIE["name"] . "<br />"; else echo "Sorry... Not recognized" . "<br />"; ?> </body> 11/28/2018

PHP Sessions Starting PHP Session Destroying PHP Session Unique identifier for each session a random string of 32 hexadecimal Starting PHP Session Call session_start() function Session variables are stored in associative array called $_SESSION[] Destroying PHP Session Call session_destroy() function Call unset( $_SESSION[‘session name’] ) to destroy single session 11/28/2018

PHP Sessions <?php session_start(); if( isset( $_SESSION['counter'] ) ){ $_SESSION['counter'] += 1; }else{ $_SESSION['counter'] = 1; } $msg = "You have visited this page ". $_SESSION['counter']; $msg .= "in this session."; ?> <html> <head> <title>Setting up a PHP session</title> </head> <body> <?php echo ( $msg ); ?> </body> </html> <?php session_destroy(); ?> <?php unset($_SESSION['counter']); ?> 11/28/2018

PHP and Database Open database connection Closing database connection connection mysql_connect(server,user,passwd,new_link,client_flag); connection mysql_connect(server,user,passwd); Closing database connection bool mysql_close ( resource $link_identifier ); <?php $dbhost = 'localhost:3036'; $dbuser = 'guest'; $dbpass = 'guest123'; $conn = mysql_connect($dbhost, $dbuser, $dbpass); if(! $conn ){ die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; mysql_close($conn); ?> 11/28/2018

PHP and Database Queries Select a database bool mysql_select_db( db_name, connection ); Execute DDL and DML Statement bool mysql_query( sql_query, connection ); Execute Fetch Data Statement $data = mysql_query( db_name, connection ); $num_rows= mysql_num_rows($data); $row = mysql_fetch_array($data, MYSQL_ASSOC) $row = mysql_fetch_assoc($data) $row = mysql_fetch_array($data, MYSQL_NUM) mysql_free_result($data); 11/28/2018

Question?

Home Task 11/28/2018

11/28/2018