 2008 Pearson Education, Inc. All rights reserved. 1 23 PHP.

Slides:



Advertisements
Similar presentations
JavaScript and AJAX Jonathan Foss University of Warwick
Advertisements

Lecture 6/2/12. Forms and PHP The PHP $_GET and $_POST variables are used to retrieve information from forms, like user input When dealing with HTML forms.
 2005 Pearson Education, Inc. All rights reserved Introduction.
Introduction to C Programming
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic PHP.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Tutorial 10 Programming with JavaScript
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
 2006 Pearson Education, Inc. All rights reserved Arrays.
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Introduction to C Programming
Introduction to scripting
 2004 Prentice Hall, Inc. All rights reserved. Chapter 25 – Perl and CGI (Common Gateway Interface) Outline 25.1 Introduction 25.2 Perl 25.3 String Processing.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 26 - PHP Outline 26.1 Introduction 26.2 PHP 26.3 String Processing and Regular Expressions 26.4.
Chapter 4: Basics of PHP 42. Topics Introduction Creating and Executing PHP Programs Variables Operators Constant Arrays String Processing and Regular.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 35 – Python Outline 35.1 Introduction First Python Program Python Keywords 35.2 Basic.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 26 - PHP Outline 26.1 Introduction 26.2 PHP 26.3 String Processing and Regular Expressions 26.4.
Chap 3: Web Programming (CCSB144) - PHP 42 Chapter 4 - PHP Outline Introduction PHP String Processing and Regular Expressions Viewing Client/Server Environment.
 2008 Pearson Education, Inc. All rights reserved PHP.
Jozef Goetz contribution, Credits: Parts of the slides are based on slides created by textbook authors, P.J. Deitel and H. M. Deitel by Prentice.
Cookies Set a cookie – setcookie() Extract data from a cookie - $_COOKIE Augment user authentication script with a cookie.
MySQL in PHP – Page 1 of 17CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: MySQL in PHP Reading: Williams &
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
INTERNET APPLICATION DEVELOPMENT For More visit:
COP 3813 Intro to Internet Computing Prof. Roy Levow PHP.
NMED 3850 A Advanced Online Design January 26, 2010 V. Mahadevan.
 2006 Pearson Education, Inc. All rights reserved Arrays.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
 2003 Prentice Hall, Inc. All rights reserved. 1 PHP Outline 26.1 Introduction 26.2 PHP 26.3 String Processing and Regular Expressions 26.4 Viewing Client/Server.
 2008 Pearson Education, Inc. All rights reserved Introduction to XHTML.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
XHTML & Forms. PHP and the WWW PHP and HTML forms – Forms are the main way users can interact with your PHP scrip Typical usage of the form tag in HTML.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP & MySQL.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Security Panel Application Introducing the Select Case Multiple-Selection Statement.
Chapter 15 Introduction to PL/SQL. Chapter Objectives  Explain the benefits of using PL/SQL blocks versus several SQL statements  Identify the sections.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
הרצאה 4. עיבוד של דף אינטרנט דינמי מתוך Murach’s PHP and MySQL by Joel Murach and Ray Harris.  דף אינטרנט דינמי משתנה עפ " י הרצת קוד על השרת, יכול להשתנות.
NMD202 Web Scripting Week5. What we will cover today PHP & MySQL Displaying Dynamic Pages Exercises Modifying Data PHP Exercises Assignment 1.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 3 – Inventory Application: Introducing Variables,
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Part:2.  Keywords are words with special meaning in JavaScript  Keyword var ◦ Used to declare the names of variables ◦ A variable is a location in the.
 2008 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 2 - Introduction to C Programming Outline.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
 2006 Pearson Education, Inc. All rights reserved Control Statements: Part 2.
Chapter 3 Part II. 3.8 Placing a Class in a Separate File for Reusability.cpp file is known as a source-code file. Header files ◦ Separate files in which.
REEM ALMOTIRI Information Technology Department Majmaah University.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Enhanced Car Payment Calculator Application Introducing Exception Handling.
 2007 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Chapter 19 PHP Part I Credits: Parts of the slides are based on slides created by textbook authors, P.J. Deitel and H. M. Deitel by Prentice Hall ©
Chapter 6 JavaScript: Introduction to Scripting
Chapter 26 - PHP Outline 26.1 Introduction 26.2 PHP
PHP Functions Besides the built-in PHP functions, we can create our own functions. A function is a block of statements that can be used repeatedly in.
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 ©
23 PHP.
Chapter 19 PHP Part II Credits: Parts of the slides are based on slides created by textbook authors, P.J. Deitel and H. M. Deitel by Prentice Hall ©
Intro to PHP & Variables
WEB PROGRAMMING JavaScript.
PHP PART 2.
JavaScript: Introduction to Scripting
23 PHP.
Presentation transcript:

 2008 Pearson Education, Inc. All rights reserved PHP

 2008 Pearson Education, Inc. All rights reserved. 2 Conversion for me was not a Damascus Road experience. I slowly moved into a intellectual acceptance of what my intuition had always known. — Madeleine L’Engle Be careful when reading health books; you may die of a misprint. — Mark Twain

 2008 Pearson Education, Inc. All rights reserved. 3 Reckoners without their host must reckon twice. — John Heywood There was a door to which I found no key; There was the veil through which I might not see. — Omar Khayyam

 2008 Pearson Education, Inc. All rights reserved. 4 OBJECTIVES In this chapter you will learn:  To manipulate data of various types.  To use operators, arrays and control statements.  To use regular expressions to search for patterns.  To construct programs that process form data.  To store data on the client using cookies.  To create programs that interact with MySQL databases.

 2008 Pearson Education, Inc. All rights reserved Introduction 23.2 PHP Basics 23.3 String Processing and Regular Expressions Comparing Strings Regular Expressions 23.4 Form Processing and Business Logic 23.5 Connecting to a Database 23.6 Using Cookies 23.7 Dynamic Content 23.8 Operator Precedence Chart 23.9 Wrap-Up Web Resources

 2008 Pearson Education, Inc. All rights reserved. 6 Outline first.php

 2008 Pearson Education, Inc. All rights reserved. 7 Common Programming Error 23.1 Failing to precede a variable name with a $ is a syntax error.

 2008 Pearson Education, Inc. All rights reserved. 8 Common Programming Error 23.2 Variable names in PHP are case sensitive. Failure to use the proper mixture of cases to refer to a variable will result in a logic error, since the script will create a new variable for any name it doesn’t recognize as a previously used variable.

 2008 Pearson Education, Inc. All rights reserved. 9 Common Programming Error 23.3 Forgetting to terminate a statement with a semicolon ( ; ) is a syntax error.

 2008 Pearson Education, Inc. All rights reserved. 10 Fig | PHP types.

 2008 Pearson Education, Inc. All rights reserved. 11 Outline data.php (1 of 3)

 2008 Pearson Education, Inc. All rights reserved. 12 Outline data.php (2 of 3)

 2008 Pearson Education, Inc. All rights reserved. 13 Outline data.php (3 of 3)

 2008 Pearson Education, Inc. All rights reserved. 14 Error-Prevention Tip 23.1 Function print can be used to display the value of a variable at a particular point during a program’s execution. This is often helpful in debugging a script.

 2008 Pearson Education, Inc. All rights reserved. 15 Common Programming Error 23.4 Assigning a value to a constant after it is declared is a syntax error.

 2008 Pearson Education, Inc. All rights reserved. 16 Outline operators.php (1 of 3)

 2008 Pearson Education, Inc. All rights reserved. 17 Outline operators.php (2 of 3)

 2008 Pearson Education, Inc. All rights reserved. 18 Outline operators.php (3 of 3)

 2008 Pearson Education, Inc. All rights reserved. 19 Error-Prevention Tip 23.2 Initialize variables before they are used to avoid subtle errors. For example, multiplying a number by an uninitialized variable results in 0.

 2008 Pearson Education, Inc. All rights reserved. 20 Fig | PHP keywords.

 2008 Pearson Education, Inc. All rights reserved. 21 Outline arrays.php (1 of 4)

 2008 Pearson Education, Inc. All rights reserved. 22 Outline arrays.php (2 of 4)

 2008 Pearson Education, Inc. All rights reserved. 23 Outline arrays.php (3 of 4)

 2008 Pearson Education, Inc. All rights reserved. 24 Outline arrays.php (4 of 4)

 2008 Pearson Education, Inc. All rights reserved. 25 Outline compare.php (1 of 2)

 2008 Pearson Education, Inc. All rights reserved. 26 Outline compare.php (2 of 2)

 2008 Pearson Education, Inc. All rights reserved. 27 Outline expression.php (1 of 2)

 2008 Pearson Education, Inc. All rights reserved. 28 Outline expression.php (2 of 2)

 2008 Pearson Education, Inc. All rights reserved. 29 Fig | Some PHP quantifiers.

 2008 Pearson Education, Inc. All rights reserved. 30 Fig | Some PHP character classes.

 2008 Pearson Education, Inc. All rights reserved. 31 Fig | Some useful superglobal arrays.

 2008 Pearson Education, Inc. All rights reserved. 32 Outline form.html (1 of 4)

 2008 Pearson Education, Inc. All rights reserved. 33 Outline form.html (2 of 4)

 2008 Pearson Education, Inc. All rights reserved. 34 Outline form.html (3 of 4)

 2008 Pearson Education, Inc. All rights reserved. 35 Outline form.html (4 of 4)

 2008 Pearson Education, Inc. All rights reserved. 36 Good Programming Practice 23.1 Use meaningful XHTML object names for input fields. This makes PHP scripts that retrieve form data easier to understand.

 2008 Pearson Education, Inc. All rights reserved. 37 Outline form.php (1 of 5)

 2008 Pearson Education, Inc. All rights reserved. 38 Outline form.php (2 of 5)

 2008 Pearson Education, Inc. All rights reserved. 39 Outline form.php (3 of 5)

 2008 Pearson Education, Inc. All rights reserved. 40 Outline form.php (4 of 5)

 2008 Pearson Education, Inc. All rights reserved. 41 Outline form.php (5 of 5)

 2008 Pearson Education, Inc. All rights reserved. 42 Software Engineering Observation 23.1 Use business logic to ensure that invalid information is not stored in databases. When possible, validate important or sensitive form data on the server, since JavaScript may be disabled by the client. Some data, such as passwords, must always be validated on the server side.

 2008 Pearson Education, Inc. All rights reserved. 43 Error-Prevention Tip 23.3 Be sure to close any open XHTML tags when calling function die. Not doing so can produce invalid XHTML output that will not display properly in the client browser. Function die has an optional parameter that specifies a message to output when exiting, so one technique for closing tags is to close all open tags using die, as in die(" ").

 2008 Pearson Education, Inc. All rights reserved. 44 Outline data.html (1 of 2)

 2008 Pearson Education, Inc. All rights reserved. 45 Outline data.html (2 of 2)

 2008 Pearson Education, Inc. All rights reserved. 46 Outline database.php (1 of 3)

 2008 Pearson Education, Inc. All rights reserved. 47 Outline database.php (2 of 3)

 2008 Pearson Education, Inc. All rights reserved. 48 Outline database.php (3 of 3)

 2008 Pearson Education, Inc. All rights reserved. 49 Outline cookies.html (1 of 2)

 2008 Pearson Education, Inc. All rights reserved. 50 Outline cookies.html (2 of 2)

 2008 Pearson Education, Inc. All rights reserved. 51 Outline cookies.php (1 of 2)

 2008 Pearson Education, Inc. All rights reserved. 52 Outline cookies.php (2 of 2)

 2008 Pearson Education, Inc. All rights reserved. 53 Software Engineering Observation 23.2 Some clients do not accept cookies. When a client declines a cookie, the browser application normally informs the user that the site may not function correctly without cookies enabled.

 2008 Pearson Education, Inc. All rights reserved. 54 Software Engineering Observation 23.3 Cookies should not be used to store addresses or private data on a client’s computer.

 2008 Pearson Education, Inc. All rights reserved. 55 Fig | IE7’s Cookies directory before a cookie is written.

 2008 Pearson Education, Inc. All rights reserved. 56 Fig | IE7’s Cookies directory after a cookie is written.

 2008 Pearson Education, Inc. All rights reserved. 57 Outline readCookies.php (1 of 2)

 2008 Pearson Education, Inc. All rights reserved. 58 Outline readCookies.php (2 of 2)

 2008 Pearson Education, Inc. All rights reserved. 59 Outline dynamicForm.php (1 of 12)

 2008 Pearson Education, Inc. All rights reserved. 60 Outline dynamicForm.php (2 of 12)

 2008 Pearson Education, Inc. All rights reserved. 61 Outline dynamicForm.php (3 of 12)

 2008 Pearson Education, Inc. All rights reserved. 62 Outline dynamicForm.php (4 of 12)

 2008 Pearson Education, Inc. All rights reserved. 63 Outline dynamicForm.php (5 of 12)

 2008 Pearson Education, Inc. All rights reserved. 64 Outline dynamicForm.php (6 of 12)

 2008 Pearson Education, Inc. All rights reserved. 65 Outline dynamicForm.php (7 of 12)

 2008 Pearson Education, Inc. All rights reserved. 66 Outline dynamicForm.php (8 of 12)

 2008 Pearson Education, Inc. All rights reserved. 67 Outline dynamicForm.php (9 of 12)

 2008 Pearson Education, Inc. All rights reserved. 68 Outline dynamicForm.php (10 of 12)

 2008 Pearson Education, Inc. All rights reserved. 69 Outline dynamicForm.php (11 of 12)

 2008 Pearson Education, Inc. All rights reserved. 70 Outline dynamicForm.php (12 of 12)

 2008 Pearson Education, Inc. All rights reserved. 71 Outline formDatabase.php (1 of 3)

 2008 Pearson Education, Inc. All rights reserved. 72 Outline formDatabase.php (2 of 3)

 2008 Pearson Education, Inc. All rights reserved. 73 Outline formDatabase.php (3 of 3)

 2008 Pearson Education, Inc. All rights reserved. 74 Fig | PHP operator precedence and associativity. (Part 1 of 3.)

 2008 Pearson Education, Inc. All rights reserved. 75 Fig | PHP operator precedence and associativity. (Part 2 of 3.)

 2008 Pearson Education, Inc. All rights reserved. 76 Fig | PHP operator precedence and associativity. (Part 3 of 3.)