PHP. Lab. de Bases de Dados e Aplicações Web MIEIC, FEUP 2010/11. Sérgio Nunes

Size: px
Start display at page:

Download "PHP. Lab. de Bases de Dados e Aplicações Web MIEIC, FEUP 2010/11. Sérgio Nunes"

Transcription

1 PHP Lab. de Bases de Dados e Aplicações Web MIEIC, FEUP 2010/11 Sérgio Nunes

2 Summary Server-Side Development The PHP Language Smarty Template Engine Database Access with MDB2

3 Server-Side Development

4 Serving Static Pages 2. Send request. 3. Receive and process request. Client Web Server 1. Set URL. 6. Render and present response. 5. Send response + file's content. Hard Disk 4. Read requested file from disk.

5 Serving Dynamic Pages 2. Send request. 3. Receive and process request. Client Web Server 1. Set URL. 9. Render and present response. 8. Send response + file's content. 5. Request PHP module to process the file. Hard Disk 7. Return results. 4. Read requested file from disk. Database APIs PHP 6. Access other resources (e.g. database, APIs, etc).

6 Use Cases Process submitted form information. Manage user authentication. Interface with other services, e.g. databases, APIs, , etc.

7 Server-Side Languages There are many server-side options. As many as programming languages. Most popular: PHP, Java, ASP, C#, Perl, Python, Ruby, etc.

8 PHP

9 Brief History Originally developed by Rasmus Lerdorf in 1994 to manage his home page. Initial acronym - "Personal Home Pages". Now "PHP: Hypertext Preprocessor". Adoption and popularity due to ease of coding and wide support in web servers.

10 A PHP Script <!DOCTYPE html> <html> <head> </head> <body> <?php echo "Hello World!";?> </body> </html> After Execution <!DOCTYPE html> <html> <head> </head> <body> Hello World! </body> </html> PHP file HTML rendered

11 Features Free and open-source. Interpreted at run-time (not compiled). Weakly typed. Supports some OO concepts.

12 phpinfo Typical way to test a server installation. Lists built-in variables and settings. Lists which modules are enabled. <?php phpinfo();?> teste.php

13 Variables Variables do not need to be declared. Names start with $ and are case sensitive. Loosely typed, i.e. variable type is dynamically defined. <?php $var = 10; $var = "text"; $var2 = TRUE;?>

14 Strings String concatenation is done with "." (dot). Supports char indexing using brackets. Common functions: explode, implode, strlen, strcmp, srtpos, substr, strtolower, strtoupper, trim <?php $var = "LBAW"; print $var[1];?> # outputs "B".

15 Arrays PHP arrays are associative, i.e. they work like a hash table with (key,value) pairs. Keys and values can be of any type. <?php $array[0] = 5; $array["age"] = 22; $array["color"] = "blue"; print_r($array); $array2 = array(5, "age"=>22, "color"=>"blue"); foreach ($array as $key => $value) echo $key. "=". $value;?>

16 Classes In PHP is possible to define classes with the class keyword. Class attributes are defined with var, and class methods are defined with function. A class must be defined in a single file.

17 Class Example <?php class Test { var $name; function getname() { return $this->name; } } function sum($v1, $v2) { return $v1 + $v2; } echo Test::sum(5, 6); // Static call. $t = new Test(); $t->name = "LBAW"; echo $t->getname();?>

18 Output The print() and echo() commands can be used to output text from the PHP code. Before any output the function header() must be called to send the HTTP required headers. Also used to send HTTP error codes (e.g. 404 File Not Found). <?php header(); print("hello world!"); print("hello world!\n"); print("string inside " are interpreted - $var"); print('strings inside ' are not interpreted - $var');?>

19 Comments <?php # single-line comment // single-line comment. /* multi-line comment */?>

20 Control Structures <?php if ($var == 5) f1(); switch ($var) { case 10: f2(); break; default: f3(); }?> <?php for ($x=1; $x<10; $x++) { print $x; } while ($x > 1) { echo $x; $x--; }?>

21 Functions The function keyword is used to define functions in PHP. It is possible to define the function parameters and their default values. Functions may return values. Variables declared within the function are local. Use the global keyword to access global variables.

22 Function Example <?php $var = 3; function sum( $val=10 ) { global $var; return $val + $var; } echo sum(); // 13 echo sum(5); // 8?>

23 Includes The include() command inserts the entire contents of a given file into the PHP script. Useful for shared libraries. Fundamental for code modularity!

24 HTTP Parameters In HTTP, both POST and GET methods can handle parameters. With GET, parameters are included in the URL, e.g. With POST, parameters are included in the HTTP headers.

25 Handling Parameters Request data is available in superglobal associative arrays: $_GET contains variables passed through HTTP GET. $_POST contains variables passed through HTTP POST. $_REQUEST contains contents of $_GET and $_POST. <?php?> $_POST["name"]; $_GET["id"]; $_REQUEST["age"];

26 Session Control

27 Session Control HTTP is a stateless protocol. Each request is independent. No built-in way of handling user interactions (e.g. user authentication, shopping carts). Two standard approaches for servers to track users: cookies and sessions.

28 Cookies Client-side information storing. Cookies are pieces of data sent by web server that can be used by browsers in subsequent requests. 1. First request. Client 2. Server response + cookie. n. Other requests + cookie. Server

29 Cookies in PHP In PHP cookies are handled using the setcookie function. Cookie values are accessible in the superglobal variable $_COOKIE. bool setcookie($name [, $value [, $expire [, $path [, $domain [, $secure ]]]]]) <?php $var = "anything"; setcookie("mycookiename", $var);?> <?php echo $_COOKIE["MyCookieName"];?>

30 Sessions Server-side information storing. A unique id (session id) is assigned to each visitor. This is information is stored in cookies or propagated via URLs. Servers store session information that is accessible using the session id as key.

31 Sessions in PHP Session handling is easy in PHP. Start a session using session_start(). After this, session variables can be created or accessed using the $_SESSION variable. A session is terminated using session_destroy(). <?php session_start(); echo session_id(); $_SESSION["prefs"] = $prefs; echo $_SESSION["prefs"]; session_destroy();?>

32 Database Access with MDB2

33 PEAR MDB2 PEAR is a framework and distribution system for reusable PHP components. PEAR MBD2 is a PHP database abstraction library. It provides a common API for RDBMS accesses. Other options: ez Database, Zend ActiveRecord, Doctrine, etc.

34 Database Connection <?php require_once 'MDB2.php'; // Data Source Name: This is the universal connection string $dsn = array( 'phptype' => 'pgsql', 'username' => 'someuser', 'password' => 'apasswd', 'hostspec' => 'localhost', 'database' => 'thedb',); $options = array( 'debug' => 2, 'portability' => MDB2_PORTABILITY_ALL,); // uses MDB2::factory() to create the instance and also attempts to connect to the host $mdb2 =& MDB2::connect($dsn, $options); if (PEAR::isError($mdb2)) { die($mdb2->getmessage()); } [...] // close connection $mdb2->disconnect();?>

35 Query Execution <?php [...] // Create a valid MDB2 object named $mdb2 at the beginning of your program require_once 'MDB2.php'; $mdb2 =& MDB2::connect('pgsql://usr:pw@localhost/dbnam'); if (PEAR::isError($mdb2)) { die($mdb2->getmessage()); } // Proceed with a query... $sql = 'SELECT * FROM clients where =? and address =?'; $data= array($ , $address)); $result =& $mdb2->query($sql, $data); // Always check that result is not an error if (PEAR::isError($result)) { die($result->getmessage()); } // Get each row of data on each iteration until there are no more rows while (($row = $res->fetchrow())) { // Assuming MDB2's default fetchmode is MDB2_FETCHMODE_ORDERED echo $row[0]. "\n"; }?>

36 Fetch Associative Arrays <?php $res = $db->query('select id, name, FROM users'); $row = $db->fetchrow($res, MDB_FETCHMODE_ASSOC); /* $row will contain: array ( 'id' => <column "id" data>, 'name' => <column "name" data>, ' ' => <column " " data> ) */ // Access the data with: $id = $row['id']; // $id = $row[0]; $name = $row['name']; // $name = $row[1]; $ = $row[' ']; // $ = $row[2];?>

37 Fetch by Number <?php [...] // the row to start fetching $from = 50; // how many results per page $respage = 10; // the last row to fetch for this page $to = $from + $respage; foreach (range($from, $to) as $rownum) { if (!$row = $db->fetchinto($res, $fetchmode, $rownum)) { break; } $id = $row['id']; // $id = $row[0]; [...] }?>

38 Insert & Update <?php // Once you have a valid MDB2 object named $mdb2... $sql = "INSERT INTO clients (id, name, address) VALUES ($id, $name, $address)"; $affected =& $mdb2->exec($sql); // Always check that result is not an error if (PEAR::isError($affected)) { die($affected->getmessage()); }?> <?php // Once you have a valid MDB2 object named $mdb2... $sql = 'UPDATE clients SET name =?, address =? WHERE id =?'; $types = array('text', 'text','integer'); $sth =& $mdb2->prepare($sql, $types, MDB2_PREPARE_MANIP); $res =& $sth->execute(array($name, $address, $id)); if (PEAR::isError($res)) die($res->getdebuginfo());?>

39 Smarty Template Engine

40 Smarty Smarty is a template engine for PHP. Enables separation between presentation layer and business logic layer. PHP was originally designed to be included in HTML files. Can easily lead to code repetition and lower readability. Harder to maintain. Different type of work can easily be separated (e.g. design vs. programming).

41 Smarty PHP file html Browser php & html code PHP file vars Smarty Template file html Browser php code html code

42 Smarty Example <?php include_once('smarty.class.php'); $smarty = new Smarty; [...] $smarty->assign('s_userid', $s_userid); $smarty->assign('s_username', $s_username); $smarty->assign('s_usertype', $s_usertype); $smarty->display('index.tpl');?> index.php <p>hello {$s_username}, glad to see you login with user {$s_userid}.</p> <p>you have privileges of {$s_usertype}.</p> index.tpl

43 Associative Arrays <?php $smarty->assign('contacts', array('fax' => ' ', ' ' => 'phone' => array('home' => ' ', 'cell' => ' ') ) ); $smarty->display('index.tpl');?> index.php {$Contacts.fax}<br /> {$Contacts. }<br /> {* you can print arrays of arrays as well *} {$Contacts.phone.home}<br /> {$Contacts.phone.cell}<br /> index.tpl

44 Common Features {include file="header.tpl" title="my Title"} includes {foreach item=user from=$users} {foreach key=type item=contact from=$user} <p>{$type}: {$contact}</p> {/foreach} {/foreach} foreach {if $type eq 2} {$name} {/if} ifs

45 Application Structure

46 User Pages PHP file include base files get data with MDB2 present with Smarty

47 Action Pages PHP file include base files get data with MDB2 redirect

48 Application Files /<webapp> PHP files. /lib Required libraries (e.g. Smarty, MBD2, etc.). /includes DB, Smarty and session setup. /database DB access files. A file per class per entity. /templates Smarty template files. /templates_c Smarty cache.

49 Example <? require_once('includes/base.php'); require_once('database/avioesmodelos.php'); $nome = $_GET["nome"]; $modelo = $_GET["modelo"]; $avioes = AvioesModelos::getByNomeModelo($nome, $modelo);?> $smarty->assign("avioes", $avioes); $smarty->display('listaravioes.tpl'); listaravioes.php

50 Example <? require_once('includes/base.php'); require_once('database/avioes.php'); if ($_POST['nome'] == "") $_SESSION['s_errors']['nome'] = 'O nome não pode ser vazio'; if ($_SESSION['s_errors']) { $_SESSION["s_values"] = $_POST; header("location: ". $_SERVER['HTTP_REFERER']); die; } if ($s_tipo!= 'admin') {header("location: index.php");die;} $nome = $_POST['nome']; $codmodelo = $_POST['codmodelo']; $errors = Avioes::insert($nome, $codmodelo);?> if ($errors) { $_SESSION["s_errors"] = $errors; $_SESSION["s_values"] = $_POST; header("location: ". $_SERVER['HTTP_REFERER']); } else { $_SESSION["s_messages"][] = "Avião Criado com Sucesso"; header("location: veraviao.php?codaviao=". Avioes::getLastInsertedId()); } accaonovoaviao.php

51 PHP.net Main PHP site Central documentation source. Supports user comments. Includes tutorials and also pointers to external resources.

52 References PHP.net PEAR MDB2 Smarty PHP Template Engine

PHP INTERVIEW QUESTION-ANSWERS

PHP INTERVIEW QUESTION-ANSWERS 1. What is PHP? PHP (recursive acronym for PHP: Hypertext Preprocessor) is the most widely used open source scripting language, majorly used for web-development and application development and can be embedded

More information

Lecture 12. PHP. cp476 PHP

Lecture 12. PHP. cp476 PHP Lecture 12. PHP 1. Origins of PHP 2. Overview of PHP 3. General Syntactic Characteristics 4. Primitives, Operations, and Expressions 5. Control Statements 6. Arrays 7. User-Defined Functions 8. Objects

More information

Database Systems Fundamentals

Database Systems Fundamentals Database Systems Fundamentals Using PHP Language Arman Malekzade Amirkabir University of Technology (Tehran Polytechnic) Notice: The class is held under the supervision of Dr.Shiri github.com/arman-malekzade

More information

URLs and web servers. Server side basics. URLs and web servers (cont.) URLs and web servers (cont.) Usually when you type a URL in your browser:

URLs and web servers. Server side basics. URLs and web servers (cont.) URLs and web servers (cont.) Usually when you type a URL in your browser: URLs and web servers 2 1 Server side basics http://server/path/file Usually when you type a URL in your browser: Your computer looks up the server's IP address using DNS Your browser connects to that IP

More information

PHP. MIT 6.470, IAP 2010 Yafim Landa

PHP. MIT 6.470, IAP 2010 Yafim Landa PHP MIT 6.470, IAP 2010 Yafim Landa (landa@mit.edu) LAMP We ll use Linux, Apache, MySQL, and PHP for this course There are alternatives Windows with IIS and ASP Java with Tomcat Other database systems

More information

Princeton University COS 333: Advanced Programming Techniques A Subset of PHP

Princeton University COS 333: Advanced Programming Techniques A Subset of PHP Princeton University COS 333: Advanced Programming Techniques A Subset of PHP Program Structure -----------------------------------------------------------------------------------

More information

CERTIFICATE IN WEB PROGRAMMING

CERTIFICATE IN WEB PROGRAMMING COURSE DURATION: 6 MONTHS CONTENTS : CERTIFICATE IN WEB PROGRAMMING 1. PROGRAMMING IN C and C++ Language 2. HTML/CSS and JavaScript 3. PHP and MySQL 4. Project on Development of Web Application 1. PROGRAMMING

More information

Chapter 7:- PHP. Compiled By:- Sanjay Patel Assistant Professor, SVBIT.

Chapter 7:- PHP. Compiled By:- Sanjay Patel Assistant Professor, SVBIT. Chapter 7:- PHP Compiled By:- Assistant Professor, SVBIT. Outline Starting to script on server side, Arrays, Function and forms, Advance PHP Databases:-Basic command with PHP examples, Connection to server,

More information

CSE 154 LECTURE 21: COOKIES

CSE 154 LECTURE 21: COOKIES CSE 154 LECTURE 21: COOKIES Regular expressions in (PDF) regex syntax: strings that begin and end with /, such as "/[AEIOU]+/" function preg_match(regex, string) preg_replace(regex, replacement, string)

More information

CSE 154 LECTURE 21: COOKIES

CSE 154 LECTURE 21: COOKIES CSE 154 LECTURE 21: COOKIES Regular expressions in (PDF) regex syntax: strings that begin and end with /, such as "/[AEIOU]+/" function preg_match(regex, string) preg_replace(regex, replacement, string)

More information

Web Application Development (WAD) V th Sem BBAITM(Unit-1) By: Binit Patel

Web Application Development (WAD) V th Sem BBAITM(Unit-1) By: Binit Patel Web Application Development (WAD) V th Sem BBAITM(Unit-1) By: Binit Patel Introduction: PHP (Hypertext Preprocessor) was invented by Rasmus Lerdorf in 1994. First it was known as Personal Home Page. Later

More information

This lecture. PHP tags

This lecture. PHP tags This lecture Databases I This covers the (absolute) basics of and how to connect to a database using MDB2. (GF Royle 2006-8, N Spadaccini 2008) I 1 / 24 (GF Royle 2006-8, N Spadaccini 2008) I 2 / 24 What

More information

Databases PHP I. (GF Royle, N Spadaccini ) PHP I 1 / 24

Databases PHP I. (GF Royle, N Spadaccini ) PHP I 1 / 24 Databases PHP I (GF Royle, N Spadaccini 2006-2010) PHP I 1 / 24 This lecture This covers the (absolute) basics of PHP and how to connect to a database using MDB2. (GF Royle, N Spadaccini 2006-2010) PHP

More information

- Origins - Rasmus Lerdorf Developed to allow him to track visitors to his Web site

- Origins - Rasmus Lerdorf Developed to allow him to track visitors to his Web site 9.1 Origins and Uses of PHP - Origins - Rasmus Lerdorf - 1994 - Developed to allow him to track visitors to his Web site - PHP was originally an acronym for Personal Home Page, but later it became PHP:

More information

Injection. CSC 482/582: Computer Security Slide #1

Injection. CSC 482/582: Computer Security Slide #1 Injection Slide #1 Topics 1. Injection Attacks 2. SQL Injection 3. Mitigating SQL Injection 4. XML Injection Slide #2 Injection Injection attacks trick an application into including unintended commands

More information

Systems Programming & Scripting

Systems Programming & Scripting Systems Programming & Scripting Lecture 19: Database Support Sys Prog & Scripting - HW Univ 1 Typical Structure of a Web Application Client Internet Web Server Application Server Database Server Third

More information

Web Scripting using PHP

Web Scripting using PHP Web Scripting using PHP Server side scripting No Scripting example - how it works... User on a machine somewhere Server machine So what is a Server Side Scripting Language? Programming language code embedded

More information

Web Programming with PHP

Web Programming with PHP We know that we can use HTML to build websites, but websites built using pure HTML suffer from a serious limitation. Imagine we want to create a website that displays the current time in Cambridge, MA,

More information

Multimedia im Netz Online Multimedia Winter semester 2015/16. Tutorial 03 Minor Subject

Multimedia im Netz Online Multimedia Winter semester 2015/16. Tutorial 03 Minor Subject Multimedia im Netz Online Multimedia Winter semester 2015/16 Tutorial 03 Minor Subject Ludwig- Maximilians- Universität München Online Multimedia WS 2015/16 - Tutorial 03-1 Today s Agenda Quick test Server

More information

Introduction. Server-side Techniques. Introduction. 2 modes in the PHP processor:

Introduction. Server-side Techniques. Introduction. 2 modes in the PHP processor: Introduction Server-side Techniques PHP Hypertext Processor A very popular server side language on web Code embedded directly into HTML documents http://hk2.php.net/downloads.php Features Free, open source

More information

Course Syllabus. Course Title. Who should attend? Course Description. PHP ( Level 1 (

Course Syllabus. Course Title. Who should attend? Course Description. PHP ( Level 1 ( Course Title PHP ( Level 1 ( Course Description PHP '' Hypertext Preprocessor" is the most famous server-side programming language in the world. It is used to create a dynamic website and it supports many

More information

COMP519 Web Programming Lecture 28: PHP (Part 4) Handouts

COMP519 Web Programming Lecture 28: PHP (Part 4) Handouts COMP519 Web Programming Lecture 28: PHP (Part 4) Handouts Ullrich Hustadt Department of Computer Science School of Electrical Engineering, Electronics, and Computer Science University of Liverpool Contents

More information

Web Development. Lab. Bases de Dados e Aplicações Web MIEIC, FEUP 10/11. Sérgio Nunes

Web Development. Lab. Bases de Dados e Aplicações Web MIEIC, FEUP 10/11. Sérgio Nunes Web Development Lab. Bases de Dados e Aplicações Web MIEIC, FEUP 10/11 Sérgio Nunes 1 Summary The Internet The World Wide Web Web Technologies 2 Introduction 3 Previous Experience? 4 Web and Internet What

More information

CONTENTS IN DETAIL INTRODUCTION 1 THE FAQS OF LIFE THE SCRIPTS EVERY PHP PROGRAMMER WANTS (OR NEEDS) TO KNOW 1 2 CONFIGURING PHP 19

CONTENTS IN DETAIL INTRODUCTION 1 THE FAQS OF LIFE THE SCRIPTS EVERY PHP PROGRAMMER WANTS (OR NEEDS) TO KNOW 1 2 CONFIGURING PHP 19 CONTENTS IN DETAIL INTRODUCTION xiii 1 THE FAQS OF LIFE THE SCRIPTS EVERY PHP PROGRAMMER WANTS (OR NEEDS) TO KNOW 1 #1: Including Another File as a Part of Your Script... 2 What Can Go Wrong?... 3 #2:

More information

4th year. more than 9 years. more than 6 years

4th year. more than 9 years. more than 6 years 4th year more than 9 years more than 6 years Apache (recommended) IIS MySQL (recommended) Oracle Client Webserver www.xyz.de Webpage (Output) Output Call MySQL-Database Dataexchange PHP Hello World

More information

B. V. Patel Institute of BMC & IT 2014

B. V. Patel Institute of BMC & IT 2014 Unit 1: Introduction Short Questions: 1. What are the rules for writing PHP code block? 2. Explain comments in your program. What is the purpose of comments in your program. 3. How to declare and use constants

More information

Lecture 7 PHP Basics. Web Engineering CC 552

Lecture 7 PHP Basics. Web Engineering CC 552 Lecture 7 PHP Basics Web Engineering CC 552 Overview n Overview of PHP n Syntactic Characteristics n Primitives n Output n Control statements n Arrays n Functions n WampServer Origins and uses of PHP n

More information

Copyright 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Chapter 11 Introduction to PHP

Copyright 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Chapter 11 Introduction to PHP Chapter 11 Introduction to PHP 11.1 Origin and Uses of PHP Developed by Rasmus Lerdorf in 1994 PHP is a server-side scripting language, embedded in XHTML pages PHP has good support for form processing

More information

PHP 5 if...else...elseif Statements

PHP 5 if...else...elseif Statements PHP 5 if...else...elseif Statements Conditional statements are used to perform different actions based on different conditions. PHP Conditional Statements Very often when you write code, you want to perform

More information

PHP + ANGULAR4 CURRICULUM 6 WEEKS

PHP + ANGULAR4 CURRICULUM 6 WEEKS PHP + ANGULAR4 CURRICULUM 6 WEEKS Hands-On Training In this course, you develop PHP scripts to perform a variety to takes, culminating in the development of a full database-driven Web page. Exercises include:

More information

Cookies and S essions 323

Cookies and S essions 323 Cookies and Sessions 9 The Hypertext Transfer Protocol (HTTP) is a stateless technology, meaning that each individual HTML page is an unrelated entity. HTTP has no method for tracking users or retaining

More information

What is PHP? [1] Figure 1 [1]

What is PHP? [1] Figure 1 [1] PHP What is PHP? [1] PHP is an acronym for "PHP: Hypertext Preprocessor" PHP is a widely-used, open source scripting language PHP scripts are executed on the server PHP is free to download and use Figure

More information

PHP by Pearson Education, Inc. All Rights Reserved.

PHP by Pearson Education, Inc. All Rights Reserved. PHP 1992-2012 by Pearson Education, Inc. All Client-side Languages User-agent (web browser) requests a web page JavaScript is executed on PC http request Can affect the Browser and the page itself http

More information

"Charting the Course... Intermediate PHP & MySQL Course Summary

Charting the Course... Intermediate PHP & MySQL Course Summary Course Summary Description In this PHP training course, students will learn to create database-driven websites using PHP and MySQL or the database of their choice. The class also covers SQL basics. Objectives

More information

ITS331 IT Laboratory I: (Laboratory #11) Session Handling

ITS331 IT Laboratory I: (Laboratory #11) Session Handling School of Information and Computer Technology Sirindhorn International Institute of Technology Thammasat University ITS331 Information Technology Laboratory I Laboratory #11: Session Handling Creating

More information

PHP Reference. To access MySQL manually, run the following command on the machine, called Sources, where MySQL and PhP have been installed:

PHP Reference. To access MySQL manually, run the following command on the machine, called Sources, where MySQL and PhP have been installed: PHP Reference 1 Preface This tutorial is designed to teach you all the PHP commands and constructs you need to complete your PHP project assignment. It is assumed that you have never programmed in PHP

More information

Running SQL in Java and PHP

Running SQL in Java and PHP Running SQL in Java and PHP FCDB 9.6 9.7 Dr. Chris Mayfield Department of Computer Science James Madison University Feb 28, 2018 Introduction to JDBC JDBC = Java Database Connectivity 1. Connect to the

More information

PHP Online Training. PHP Online TrainingCourse Duration - 45 Days. Call us: HTML

PHP Online Training. PHP Online TrainingCourse Duration - 45 Days.  Call us: HTML PHP Online Training PHP is a server-side scripting language designed for web development but also used as a generalpurpose programming language. PHP is now installed on more than 244 million websites and

More information

Web development with PHP. Kore Nordmann, Tobias Schlitt, Jakob Westhoff Dortmund

Web development with PHP. Kore Nordmann, Tobias Schlitt, Jakob Westhoff Dortmund Web development with PHP Kore Nordmann, Tobias Schlitt, Jakob Westhoff Dortmund 29.06.09 Speaker Jakob Westhoff Kore Nordmann Tobias Schlitt Active in various

More information

CITS1231 Web Technologies. PHP s, Cookies and Session Control

CITS1231 Web Technologies. PHP  s, Cookies and Session Control CITS1231 Web Technologies PHP Emails, Cookies and Session Control Sending email with PHP We have looked at storing user information using files. Email messages can also be thought of as data streams, providing

More information

PHP CURRICULUM 6 WEEKS

PHP CURRICULUM 6 WEEKS PHP CURRICULUM 6 WEEKS Hands-On Training In this course, you develop PHP scripts to perform a variety to takes, culminating in the development of a full database-driven Web page. Exercises include: Accessing

More information

Server-Side Web Programming: Python (Part 1) Copyright 2017 by Robert M. Dondero, Ph.D. Princeton University

Server-Side Web Programming: Python (Part 1) Copyright 2017 by Robert M. Dondero, Ph.D. Princeton University Server-Side Web Programming: Python (Part 1) Copyright 2017 by Robert M. Dondero, Ph.D. Princeton University 1 Objectives You will learn about Server-side web programming in Python Common Gateway Interface

More information

Hello everyone! Page 1. Your folder should look like this. To start with Run your XAMPP app and start your Apache and MySQL.

Hello everyone! Page 1. Your folder should look like this. To start with Run your XAMPP app and start your Apache and MySQL. Hello everyone! Welcome to our PHP + MySQL (Easy to learn) E.T.L. free online course Hope you have installed your XAMPP? And you have created your forms inside the studio file in the htdocs folder using

More information

Running SQL in Java and PHP

Running SQL in Java and PHP Running SQL in Java and PHP FCDB 9.6 9.7 Dr. Chris Mayfield Department of Computer Science James Madison University Mar 01, 2017 Introduction to JDBC JDBC = Java Database Connectivity 1. Connect to the

More information

How browsers talk to servers. What does this do?

How browsers talk to servers. What does this do? HTTP HEADERS How browsers talk to servers This is more of an outline than a tutorial. I wanted to give our web team a quick overview of what headers are and what they mean for client-server communication.

More information

The PHP language. Teaching you everything about PHP? Not exactly Goal: teach you how to interact with a database via web

The PHP language. Teaching you everything about PHP? Not exactly Goal: teach you how to interact with a database via web Web programming The PHP language Our objective Teaching you everything about PHP? Not exactly Goal: teach you how to interact with a database via web Access data inserted by users into HTML forms Interact

More information

Server side basics CS380

Server side basics CS380 1 Server side basics URLs and web servers 2 http://server/path/file Usually when you type a URL in your browser: Your computer looks up the server's IP address using DNS Your browser connects to that IP

More information

Server side basics CSC 210

Server side basics CSC 210 1 Server side basics Be careful 2 Do not type any command starting with sudo into a terminal attached to a university computer. You have complete control over you AWS server, just as you have complete

More information

John Valance JValance Consulting

John Valance JValance Consulting John Valance JValance Consulting jvalance@sprynet.com Copyright 2011-2012: John Valance Independent consultant o Specialty is helping iseries shops develop web applications, and related skills o Training,

More information

COMS 469: Interactive Media II

COMS 469: Interactive Media II COMS 469: Interactive Media II Agenda Project One PHP Preview Project One Grading Methodology Return Project One & Evaluation Sheet Project One Evaluation Methodology Consider each project in and of itself

More information

1) What is the first step of the system development life cycle (SDLC)? A) Design B) Analysis C) Problem and Opportunity Identification D) Development

1) What is the first step of the system development life cycle (SDLC)? A) Design B) Analysis C) Problem and Opportunity Identification D) Development Technology In Action, Complete, 14e (Evans et al.) Chapter 10 Behind the Scenes: Software Programming 1) What is the first step of the system development life cycle (SDLC)? A) Design B) Analysis C) Problem

More information

PHP: Cookies, Sessions, Databases. CS174. Chris Pollett. Sep 24, 2008.

PHP: Cookies, Sessions, Databases. CS174. Chris Pollett. Sep 24, 2008. PHP: Cookies, Sessions, Databases. CS174. Chris Pollett. Sep 24, 2008. Outline. How cookies work. Cookies in PHP. Sessions. Databases. Cookies. Sometimes it is useful to remember a client when it comes

More information

PHP. Interactive Web Systems

PHP. Interactive Web Systems PHP Interactive Web Systems PHP PHP is an open-source server side scripting language. PHP stands for PHP: Hypertext Preprocessor One of the most popular server side languages Second most popular on GitHub

More information

You can also set the expiration time of the cookie in another way. It may be easier than using seconds.

You can also set the expiration time of the cookie in another way. It may be easier than using seconds. What is a Cookie? A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each time the same computer requests a page with a browser, it will

More information

Web development using PHP & MySQL with HTML5, CSS, JavaScript

Web development using PHP & MySQL with HTML5, CSS, JavaScript Web development using PHP & MySQL with HTML5, CSS, JavaScript Static Webpage Development Introduction to web Browser Website Webpage Content of webpage Static vs dynamic webpage Technologies to create

More information

Lecture 7: Dates/Times & Sessions. CS 383 Web Development II Wednesday, February 14, 2018

Lecture 7: Dates/Times & Sessions. CS 383 Web Development II Wednesday, February 14, 2018 Lecture 7: Dates/Times & Sessions CS 383 Web Development II Wednesday, February 14, 2018 Date/Time When working in PHP, date is primarily tracked as a UNIX timestamp, the number of seconds that have elapsed

More information

Chapters 10 & 11 PHP AND MYSQL

Chapters 10 & 11 PHP AND MYSQL Chapters 10 & 11 PHP AND MYSQL Getting Started The database for a Web app would be created before accessing it from the web. Complete the design and create the tables independently. Use phpmyadmin, for

More information

PHP 1. Introduction Temasek Polytechnic

PHP 1. Introduction Temasek Polytechnic PHP 1 Introduction Temasek Polytechnic Background Open Source Apache License Free to redistribute with/without source code http://www.apache.org/license.txt Backed by Zend Corporation http://www.zend.com

More information

DevShala Technologies A-51, Sector 64 Noida, Uttar Pradesh PIN Contact us

DevShala Technologies A-51, Sector 64 Noida, Uttar Pradesh PIN Contact us INTRODUCING PHP The origin of PHP PHP for Web Development & Web Applications PHP History Features of PHP How PHP works with the Web Server What is SERVER & how it works What is ZEND Engine Work of ZEND

More information

PHP Introduction. Some info on MySQL which we will cover in the next workshop...

PHP Introduction. Some info on MySQL which we will cover in the next workshop... PHP and MYSQL PHP Introduction PHP is a recursive acronym for PHP: Hypertext Preprocessor -- It is a widely-used open source general-purpose serverside scripting language that is especially suited for

More information

WEB APPLICATION ENGINEERING II

WEB APPLICATION ENGINEERING II WEB APPLICATION ENGINEERING II Lecture #5 Umar Ibrahim Enesi Objectives Gain understanding of how Cookies and Sessions Work Understand the limitations of Sessions and Cookies Understand how to handle Session

More information

Hands-On Perl Scripting and CGI Programming

Hands-On Perl Scripting and CGI Programming Hands-On Course Description This hands on Perl programming course provides a thorough introduction to the Perl programming language, teaching attendees how to develop and maintain portable scripts useful

More information

Create-A-Page Design Documentation

Create-A-Page Design Documentation Create-A-Page Design Documentation Group 9 C r e a t e - A - P a g e This document contains a description of all development tools utilized by Create-A-Page, as well as sequence diagrams, the entity-relationship

More information

Fachgebiet Technische Informatik, Joachim Zumbrägel

Fachgebiet Technische Informatik, Joachim Zumbrägel Computer Network Lab 2017 Fachgebiet Technische Informatik, Joachim Zumbrägel Overview Internet Internet Protocols Fundamentals about HTTP Communication HTTP-Server, mode of operation Static/Dynamic Webpages

More information

Web Scripting using PHP

Web Scripting using PHP Web Scripting using PHP Server side scripting So what is a Server Side Scripting Language? Programming language code embedded into a web page PERL PHP PYTHON ASP Different ways of scripting the Web Programming

More information

INTERVIEW QUESTIONS - PHP JOB 2014 (HTML)

INTERVIEW QUESTIONS - PHP JOB 2014 (HTML) INTERVIEW QUESTIONS - PHP JOB 2014 (HTML) 1. Who is the father of PHP? 2. Current version of PHP? 3. What is Zend engine? 4. Definition of PHP? 5. Is html embed in PHP? 6. What is!doctype? 7. What is responsive

More information

Get in Touch Module 1 - Core PHP XHTML

Get in Touch Module 1 - Core PHP XHTML PHP/MYSQL (Basic + Advanced) Web Technologies Module 1 - Core PHP XHTML What is HTML? Use of HTML. Difference between HTML, XHTML and DHTML. Basic HTML tags. Creating Forms with HTML. Understanding Web

More information

Getting started 7. Performing operations 25

Getting started 7. Performing operations 25 Contents Contents 1 2 3 Getting started 7 Introducing PHP & MySQL 8 Understanding the cloud 9 Installing Abyss Web Server 10 Installing the PHP engine 12 Configuring Abyss for PHP 14 Embedding PHP script

More information

PHP: Hypertext Preprocessor. A tutorial Introduction

PHP: Hypertext Preprocessor. A tutorial Introduction PHP: Hypertext Preprocessor A tutorial Introduction Introduction PHP is a server side scripting language Primarily used for generating dynamic web pages and providing rich web services PHP5 is also evolving

More information

Solution of Exercise Sheet 5

Solution of Exercise Sheet 5 Foundations of Cybersecurity (Winter 16/17) Prof. Dr. Michael Backes CISPA / Saarland University saarland university computer science Solution of Exercise Sheet 5 1 SQL Injection Consider a website foo.com

More information

php works 2006 in Toronto Lukas Kahwe Smith

php works 2006 in Toronto Lukas Kahwe Smith Building Portable Database Applications php works 2006 in Toronto Lukas Kahwe Smith smith@pooteeweet.org Agenda: Overview Introduction ext/pdo PEAR::MDB2 ORM and ActiveRecord SQL Syntax Result Sets High

More information

DATABASE SYSTEMS. Introduction to web programming. Database Systems Course, 2016

DATABASE SYSTEMS. Introduction to web programming. Database Systems Course, 2016 DATABASE SYSTEMS Introduction to web programming Database Systems Course, 2016 AGENDA FOR TODAY Client side programming HTML CSS Javascript Server side programming: PHP Installing a local web-server Basic

More information

AJAX. Lab. de Bases de Dados e Aplicações Web MIEIC, FEUP 2010/11. Sérgio Nunes

AJAX. Lab. de Bases de Dados e Aplicações Web MIEIC, FEUP 2010/11. Sérgio Nunes AJAX Lab. de Bases de Dados e Aplicações Web MIEIC, FEUP 2010/11 Sérgio Nunes Server calls from web pages using JavaScript call HTTP data Motivation The traditional request-response cycle in web applications

More information

Mobile Site Development

Mobile Site Development Mobile Site Development HTML Basics What is HTML? Editors Elements Block Elements Attributes Make a new line using HTML Headers & Paragraphs Creating hyperlinks Using images Text Formatting Inline styling

More information

UFCEKG Lecture 4 Server Side Scripting & PHP

UFCEKG Lecture 4 Server Side Scripting & PHP UFCEKG 20 2 Data, Schemas & Applications Lecture 4 Server Side Scripting & PHP Last week: o encode data for communication o card based o csv o tagged records o Xml o xml vocabularies o xml processing vocabularies

More information

Database Applications

Database Applications Database Applications Database Programming Application Architecture Objects and Relational Databases John Edgar 2 Users do not usually interact directly with a database via the DBMS The DBMS provides

More information

PHP Development - Introduction

PHP Development - Introduction PHP Development - Introduction Php Hypertext Processor PHP stands for PHP: Hypertext Preprocessor PHP is a server-side scripting language, like ASP PHP scripts are executed on the server PHP supports many

More information

Managing State. Chapter 13

Managing State. Chapter 13 Managing State Chapter 13 Textbook to be published by Pearson Ed 2015 in early Pearson 2014 Fundamentals of Web http://www.funwebdev.com Development Section 1 of 8 THE PROBLEM OF STATE IN WEB APPLICATIONS

More information

CN Assignment I. 1. With an example explain how cookies are used in e-commerce application to improve the performance.

CN Assignment I. 1. With an example explain how cookies are used in e-commerce application to improve the performance. CN Assignment I 1. With an example explain how cookies are used in e-commerce application to improve the performance. In an e-commerce application, when the user sends a login form to the server, the server

More information

PHP 5. André Restivo 1 / 108

PHP 5. André Restivo 1 / 108 PHP 5 André Restivo 1 / 108 Index Introduction Variables Control Structures Strings Arrays Functions Classes Exceptions Databases HTTP Parameters Sessions Passwords Headers Includes JSON Best Practices

More information

Integrity attacks (from data to code): Malicious File upload, code execution, SQL Injection

Integrity attacks (from data to code): Malicious File upload, code execution, SQL Injection Pattern Recognition and Applications Lab Integrity attacks (from data to code): Malicious File upload, code execution, SQL Injection Igino Corona igino.corona _at_ diee.unica.it Computer Security May 2nd,

More information

Quiz 1 Review Session. November 17th, 2014

Quiz 1 Review Session. November 17th, 2014 Quiz 1 Review Session November 17th, 2014 Topics (non-exhaustive) pointers linked lists hash tables trees tries stacks queues TCP/IP HTTP HTML CSS PHP MVC SQL HTTP statuses DOM JavaScript jquery Ajax security...

More information

Autopopulation; Session & Cookies

Autopopulation; Session & Cookies ; Session & Cookies CGT 356 Web Programming, Development, & Database Integration Lecture 5 Session array Use the Session array to store data that needs to be recalled on later pages $_SESSION[ foo ] Use

More information

This is CS50. Harvard College Fall Quiz 1 Answer Key

This is CS50. Harvard College Fall Quiz 1 Answer Key Quiz 1 Answer Key Answers other than the below may be possible. Know Your Meme. 0. True or False. 1. T 2. F 3. F 4. F 5. T Attack. 6. By never making assumptions as to the length of users input and always

More information

Review. Fundamentals of Website Development. Web Extensions Server side & Where is your JOB? The Department of Computer Science 11/30/2015

Review. Fundamentals of Website Development. Web Extensions Server side & Where is your JOB? The Department of Computer Science 11/30/2015 Fundamentals of Website Development CSC 2320, Fall 2015 The Department of Computer Science Review Web Extensions Server side & Where is your JOB? 1 In this chapter Dynamic pages programming Database Others

More information

PHP APIs. Rapid Learning & Just In Time Support

PHP APIs. Rapid Learning & Just In Time Support PHP APIs Rapid Learning & Just In Time Support CONTENT 1 INTRODUCTION... 3 1.1 Create PHP Application... 4 1.1.1 Create PHP Console Application... 4 1.1.2 Create PHP Web Application... 4 2 DATA BASE...

More information

Web Programming 4) PHP and the Web

Web Programming 4) PHP and the Web Web Programming 4) PHP and the Web Emmanuel Benoist Fall Term 2013-14 Berner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 1 PHP a language for Web applications Presentation

More information

Some things to watch out for when using PHP and Javascript when building websites

Some things to watch out for when using PHP and Javascript when building websites Some things to watch out for when using PHP and Javascript when building websites Les Hatton 10 Sep 2003 1 PHP PHP is a C-like language which evolved from Perl scripts originally produced by Rasmus Lerdorf

More information

- Origins - Rasmus Lerdorf Developed to allow him to track visitors to his Web site

- Origins - Rasmus Lerdorf Developed to allow him to track visitors to his Web site 9.1 Origins and Uses of PHP - Origins - Rasmus Lerdorf - 1994 - Developed to allow him to track visitors to his Web site - PHP is an open-source product - PHP was originally an acronym for Personal Home

More information

WebsitePanel User Guide

WebsitePanel User Guide WebsitePanel User Guide User role in WebsitePanel is the last security level in roles hierarchy. Users are created by reseller and they are consumers of hosting services. Users are able to create and manage

More information

Lecture 6 Session Control and User Authentication. INLS 760 Web Databases Spring 2013 Rob Capra

Lecture 6 Session Control and User Authentication. INLS 760 Web Databases Spring 2013 Rob Capra Lecture 6 Session Control and User Authentication INLS 760 Web Databases Spring 2013 Rob Capra HTML Forms and PHP PHP: lect2/form1.php echo "Hello, ". htmlspecialchars(strip_tags($_get['name'])); echo

More information

PIC 40A. Lecture 19: PHP Form handling, session variables and regular expressions. Copyright 2011 Jukka Virtanen UCLA 1 05/25/12

PIC 40A. Lecture 19: PHP Form handling, session variables and regular expressions. Copyright 2011 Jukka Virtanen UCLA 1 05/25/12 PIC 40A Lecture 19: PHP Form handling, session variables and regular expressions 05/25/12 Copyright 2011 Jukka Virtanen UCLA 1 How does a browser communicate with a program on a server? By submitting an

More information

ICOM 5016 Database Systems. Database Users. User Interfaces and Tools. Chapter 8: Application Design and Development.

ICOM 5016 Database Systems. Database Users. User Interfaces and Tools. Chapter 8: Application Design and Development. Chapter 8: Application Design and Development ICOM 5016 Database Systems Web Application Amir H. Chinaei Department of Electrical and Computer Engineering University of Puerto Rico, Mayagüez User Interfaces

More information

Working with the Seagull Framework. By Demian Turner, Seagull Systems

Working with the Seagull Framework. By Demian Turner, Seagull Systems Working with the Seagull Framework By Demian Turner, Seagull Systems seagullproject.org Who is Demian Turner? Developing websites since 1996, using PHP since 1999 Committer on several open source projects:

More information

Static Webpage Development

Static Webpage Development Dear Student, Based upon your enquiry we are pleased to send you the course curriculum for PHP Given below is the brief description for the course you are looking for: - Static Webpage Development Introduction

More information

CPET 499/ITC 250 Web Systems. Topics

CPET 499/ITC 250 Web Systems. Topics CPET 499/ITC 250 Web Systems Chapter 13 Managing State Text Book: * Fundamentals of Web Development, 2015, by Randy Connolly and Ricardo Hoar, published by Pearson Paul I-Hai, Professor http://www.etcs.ipfw.edu/~lin

More information

Web technologies. Web. basic components. embellishments in browser. DOM (document object model)

Web technologies. Web. basic components. embellishments in browser. DOM (document object model) Web technologies DOM (document object model) what's on the page and how it can be manipulated forms / CGI (common gateway interface) extract info from a form, create a page, send it back server side code

More information

Mount Saint Mary College, Newburgh, NY Internet Programming III - CIT310

Mount Saint Mary College, Newburgh, NY Internet Programming III - CIT310 Warm up mini-lab Lab 1 - Functions Type in the following function definition and calls to the function. Test it and understand it. function myprint($str= No String Supplied ) // the argument is optional

More information

Database Systems Fundamentals

Database Systems Fundamentals Database Systems Fundamentals Using PHP Language Arman Malekzade Amirkabir University of Technology (Tehran Polytechnic) Notice: The class is held under the supervision of Dr.Shiri github.com/arman-malekzade

More information

Core PHP. PHP output mechanism. Introducing. Language basics. Installing & Configuring PHP. Introducing of PHP keywords. Operators & expressions

Core PHP. PHP output mechanism. Introducing. Language basics. Installing & Configuring PHP. Introducing of PHP keywords. Operators & expressions Core PHP Introducing The origin of PHP PHP for web Development & Web Application PHP History Features of PHP How PHP works with the server What is server & how it works Installing & Configuring PHP PHP

More information