Copyright © 2003 Pearson Education, Inc. Slide 7-1 The Web Wizard’s Guide to PHP by David Lash.

Slides:



Advertisements
Similar presentations
Copyright © 2003 Pearson Education, Inc. Slide 7-1 The Web Wizards Guide to PHP by David Lash.
Advertisements

Copyright © 2003 Pearson Education, Inc. Slide 6b-1 The Web Wizards Guide to PHP by David Lash.
1 Copyright © 2002 Pearson Education, Inc.. 2 Chapter 8 Managing End-User Sessions.
Cookies, Sessions. Server Side Includes You can insert the content of one file into another file before the server executes it, with the require() function.
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.
1 Chapter 5 – Handling HTML Controls in Web Pages spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science.
CIS101 Introduction to Computing Week 08. Agenda Your questions JavaScript text Resume project HTML Project Six This week online Next class.
Copyright © 2003 Pearson Education, Inc. Slide 6b-1 The Web Wizard’s Guide to PHP by David Lash.
1 Copyright © 2002 Pearson Education, Inc.. 2 Chapter 8 Managing End-User Sessions.
XP Tutorial 9 New Perspectives on JavaScript, Comprehensive1 Working with Cookies Managing Data in a Web Site Using JavaScript Cookies.
Chapter 10 Managing State Information PHP Programming with MySQL.
Session Management A290/A590, Fall /25/2014.
1 The World Wide Web. 2  Web Fundamentals  Pages are defined by the Hypertext Markup Language (HTML) and contain text, graphics, audio, video and software.
1 PHP and MySQL David Lash Module 2 Working with forms, PHP conditionals and loops.
Chapter 10 Form Basics Key Concepts Copyright © 2013 Terry Ann Morris, Ed.D 1.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
1 Web Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
_______________________________________________________________________________________________________________ E-Commerce: Fundamentals and Applications1.
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
INTERNET APPLICATION DEVELOPMENT For More visit:
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Cookies & Sessions.
CHAPTER 12 COOKIES AND SESSIONS. INTRO HTTP is a stateless technology Each page rendered by a browser is unrelated to other pages – even if they are from.
Comp2513 Forms and CGI Server Applications Daniel L. Silver, Ph.D.
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizard’s Guide to PHP by David Lash.
Chapter 16 The World Wide Web. 2 The Web An infrastructure of information combined and the network software used to access it Web page A document that.
Working with Cookies Managing Data in a Web Site Using JavaScript Cookies* *Check and comply with the current legislation regarding handling cookies.
Week seven CIT 354 Internet II. 2 Objectives Database_Driven User Authentication Using Cookies Session Basics Summary Homework and Project 2.
PHP1-1 PHP Lecture 2 Xingquan (Hill) Zhu
Lecture 8 – Cookies & Sessions SFDV3011 – Advanced Web Development 1.
Slide 7-1 CHAPTER 7 Managing Multiple-Form Applications: Writing scripts with multiple screens.
1 Chapter 9 – Cookies, Sessions, FTP, and More spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science.
Week 9 - Form Basics Key Concepts 1. 1.Describe common uses of forms on web pages 2.Create forms on web pages using the form, input, textarea, and select.
Cookies & Session Web Technology
STATE MANAGEMENT.  Web Applications are based on stateless HTTP protocol which does not retain any information about user requests  The concept of state.
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.
PHP Programming with MySQL Slide 10-1 CHAPTER 10 Managing State Information.
Topics Sending an Multipart message Storing images Getting confirmation Session tracking using PHP Graphics Input Validators Cookies.
PHP. $_GET / $_POST / $_SESSION PHP uses predefined variables to provide access to important information about the server and requests from a browser.
COOKIES and SESSIONS. COOKIES 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.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 9 Key Concepts 1 Copyright © Terry Felke-Morris.
Copyright © 2003 Pearson Education, Inc. Slide 6a-1 The Web Wizard’s Guide to PHP by David Lash.
Web Database Programming Week 7 Session Management & Authentication.
Cookies and Sessions IDIA 618 Fall 2014 Bridget M. Blodgett.
Sessions and Cookies State Management, Cookies, Sessions, Hidden Fields SoftUni Team Technical Trainers Software University
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 9 Key Concepts 1 Copyright © Terry Felke-Morris.
Copyright © Texas Education Agency, All rights reserved.1 Web Technologies Website Forms / Data Acquisition.
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Form Processing Week Four. Form Processing Concepts The principal tool used to process Web forms stored on UNIX servers is a CGI (Common Gateway Interface)
Fundamentals of Web DevelopmentRandy Connolly and Ricardo HoarFundamentals of Web DevelopmentRandy Connolly and Ricardo Hoar Fundamentals of Web DevelopmentRandy.
1 State and Session Management HTTP is a stateless protocol – it has no memory of prior connections and cannot distinguish one request from another. The.
ITM © Port,Kazman 1 ITM 352 Cookies. ITM © Port,Kazman 2 Problem… r How do you identify a particular user when they visit your site (or any.
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.
Cookies and Sessions in PHP. Arguments for the setcookie() Function There are several arguments you can use i.e. setcookie(‘name’, ‘value’, expiration,
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.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
Copyright © 2003 Pearson Education, Inc. Slide 7-1 The Web Wizard’s Guide to PHP by David Lash.
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
PHP: Further Skills 02 By Trevor Adams. Topics covered Persistence What is it? Why do we need it? Basic Persistence Hidden form fields Query strings Cookies.
FORMS Explained By: Jasdeep Kaur. Lecturer, Department of Computer Application, PGG.C.G., Sector: 42, Chandigarh.
Fundamentals of Web DevelopmentRandy Connolly and Ricardo HoarFundamentals of Web DevelopmentRandy Connolly and Ricardo Hoar Fundamentals of Web DevelopmentRandy.
Managing State Chapter 13.
WWW and HTTP King Fahd University of Petroleum & Minerals
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.
ITM 352 Cookies.
What is Cookie? Cookie is small information stored in text file on user’s hard drive by web server. This information is later used by web browser to retrieve.
Web Systems Development (CSC-215)
Web Development & Design Foundations with H T M L 5
Creating Forms on a Web Page
PHP-II.
Presentation transcript:

Copyright © 2003 Pearson Education, Inc. Slide 7-1 The Web Wizard’s Guide to PHP by David Lash

Copyright © 2003 Pearson Education, Inc. Slide 7-2 CHAPTER 7 Managing Multiple-Form Applications: Writing scripts with multiple screens

Copyright © 2003 Pearson Education, Inc. Slide 7-3 Objectives To understand what are multiple-form Web sessions To learn how to use hidden fields to build multiple- form user sessions To learn how to use browser cookies to track data about the user To learn how to use PHP session functions and how to use them to track data about the user

Copyright © 2003 Pearson Education, Inc. Slide 7-4 What Are Multiple-Form Web Sessions? A multiple-form Web session leads the user through a series of HTML forms that work together and pass data from form to form. E.g., a shopping cart or on-line survey.

Copyright © 2003 Pearson Education, Inc. Slide 7-5 Example Multiple Screen Session

Copyright © 2003 Pearson Education, Inc. Slide 7-6 Using Hidden Fields to Pass Data Hidden fields are part of HTML forms Not displayed but value can be accessed in receiving script like any other variable. Can still be viewed by user’s who view source.

Copyright © 2003 Pearson Education, Inc. Slide 7-7 A Full Script Example Consider an example script that sets a hidden field Implements the Order Info form On submit sends data to order2.php

Copyright © 2003 Pearson Education, Inc. Slide 7-8 PHP Script 1. Order Product 2. <form action=" method="post"> 3. Happy Harry's Hardware Product Order Form We have hammers, handsaws, and wrenches on special today! Enter Item: 9. Enter Quantity:

Copyright © 2003 Pearson Education, Inc. Slide 7-9 The Output... The previous code can be executed at

Copyright © 2003 Pearson Education, Inc. Slide 7-10 Receiving Hidden Fields in Web Sessions Your scripts can receive data from hidden fields like any other data. Suppose the following is stored at order2.php

Copyright © 2003 Pearson Education, Inc. Slide 7-11 Receiving PHP Show Source Code

Copyright © 2003 Pearson Education, Inc. Slide 7-12 Sending from PHP scripts Sometimes it is useful to send from a PHP script: PHP uses mail() that by default sends via the Simple Mail Transfer Protocol (SMTP). mail(to_address, subject, message, extra_headers); Specify the destination address. Specify the subject line of the . Specify the Text of the Specify additional headers.

Copyright © 2003 Pearson Education, Inc. Slide 7-13 Consider the following example … $subject = 'New Hardware Order'; 3. $message = 'Enclosed is a new order for 12 hammers.\n Thanks.'; 4. $extra = 'From: 5. mail( $dest, $subject, $message, $extra );

Copyright © 2003 Pearson Education, Inc. Slide 7-14 Consider the following full example … Implements save and notify Called from order2.php and saved at order3.php Can access variables $product, $quantity, and $sample_hidden sent as hidden fields from the Billing Info form.

Copyright © 2003 Pearson Education, Inc. Slide 7-15 The following PHP Script Show Source Code

Copyright © 2003 Pearson Education, Inc. Slide 7-16 Would have the following output …

Copyright © 2003 Pearson Education, Inc. Slide 7-17 Would have the following output …

Copyright © 2003 Pearson Education, Inc. Slide 7-18 Using Browser Cookies … Cookies are small pieces of data that a Web application can save when a user visits the Web page. Stored on the visitor’s hard drive A web page script can read the previously stored browser cookie data

Copyright © 2003 Pearson Education, Inc. Slide 7-19 Understanding Cookie Limitations Users can easily disable the cookies feature. People move around. Users may delete cookies. PHP sets limit on cookies

Copyright © 2003 Pearson Education, Inc. Slide 7-20 Setting and Reading Cookies Cookies can be set in memory or on hard disk Set in memory are deleted when browser closes Can use the setcookie() functionsetcookie() setcookie('Customer_name', 'Denise'); Directs browser to create a cookie Specify the cookie’s name Specify the cookie’s value

Copyright © 2003 Pearson Education, Inc. Slide 7-21 Setting A Cookie on a Hard Drive You need to use the time() function when you want to set a cookie on a hard drive.

Copyright © 2003 Pearson Education, Inc. Slide 7-22 A full example of setting a cookie…. Suppose a front-end web page asks for some survey information: <input type="radio" name="prefers" value="power tools" checked > Power Tools? <input type="radio" name="prefers" value="hand tools"> Hand Tools? <input type="radio" name="prefers” value="air fresheners"> Air Fresheners?

Copyright © 2003 Pearson Education, Inc. Slide 7-23 The following script runs when submitted: Show Source Code

Copyright © 2003 Pearson Education, Inc. Slide 7-24 Would output: The previous code can be executed at:

Copyright © 2003 Pearson Education, Inc. Slide 7-25 Reading Cookies To read a cookie value use the $_COOKIE[ ] associative array to get a cookie value $cust_name= $_COOKIE[“cust_name”];

Copyright © 2003 Pearson Education, Inc. Slide 7-26 Example Script that read a cookie Show Source Code Execute code:

Copyright © 2003 Pearson Education, Inc. Slide 7-27 PHP Sessions PHP supports sessions that enable you to retain data between forms session_start() - either starts a new session or resumes one if a session exists Run at the start of every script By default creates a unique session ID stored as a cookie Session variables are accessed through the $_SESSION associative array.

Copyright © 2003 Pearson Education, Inc. Slide 7-28 Example PHP Code Source Code

Copyright © 2003 Pearson Education, Inc. Slide 7-29 Use the following script to read the session data Source Code

Copyright © 2003 Pearson Education, Inc. Slide 7-30 Example output This script can be executed at:

Copyright © 2003 Pearson Education, Inc. Slide 7-31 Summary Hidden fields are HTML form fields you can use to set a variable name and variable value without displaying them on a form. Cookies provide a way for Web server applications to store small pieces of data on the user’s hard disk. PHP session functions provide a convenient way to retain data between PHP scripts. Use the session_start() function to start sessions