1 CS428 Web Engineering Lecture 22 Building Dynamic Web pages (PHP - V)

Slides:



Advertisements
Similar presentations
LIS651 lecture 3 taming PHP Thomas Krichel
Advertisements

LIS651 lecture 3 functions & sessions Thomas Krichel
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.
The Web Warrior Guide to Web Design Technologies
Php cookies & sessions.
PHP Forms. I. Using PHP with HTML Forms A very common application of PHP is to have an HTML form gather information from a website's visitor and then.
FILE UPLOADS CHAPTER 11. THE BASIC PROCESS 1.The HTML form displays the control to locate and upload a file 2.Upon form submission, the server first stores.
SE-2840 Dr. Mark L. Hornick1 Java Servlet-based web apps Servlet Architecture.
1 CS428 Web Engineering Lecture 18 Introduction (PHP - I)
Chapter 4 Mixing PHP and HTML  In this chapter, you’ll learn how to do the following: -Recognize and use the different kinds of PHP start and end tags.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
PHP Workshop ‹#› PHP: The Basics. PHP Workshop ‹#› What is it? PHP is a scripting language commonly used on web servers. –Stands for “PHP: Hypertext Preprocessor”
ITM © Port, Kazman1 ITM 352 HTML Forms, Basic Form Processing.
PHP Security.
Advance Database Management Systems Lab no. 5 PHP Web Pages.
Application Development Description and exemplification of server-side scripting language for server connection, database selection, execution of SQL queries.
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:
Lecture 6 – Form processing (Part 1) SFDV3011 – Advanced Web Development 1.
Lecture 7 – Form processing (Part 2) SFDV3011 – Advanced Web Development 1.
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.
CSC 2720 Building Web Applications Cookies, URL-Rewriting, Hidden Fields and Session Management.
Lecture 14 – Web Security SFDV3011 – Advanced Web Development 1.
Week 9 PHP Cookies and Session Introduction to JavaScript.
Accessing MySQL with PHP IDIA 618 Fall 2014 Bridget M. Blodgett.
12/3/2012ISC329 Isabelle Bichindaritz1 PHP and MySQL Advanced Features.
Lecture 8 – Cookies & Sessions SFDV3011 – Advanced Web Development 1.
Nic Shulver, Introduction to Sessions in PHP Sessions What is a session? Example Software Software Organisation The login HTML.
Chapter 6: Authentications. Training Course, CS, NCTU 2 Overview  Getting Username and Password  Verifying Username and Password  Keeping The Verification.
Forms and Server Side Includes. What are Forms? Forms are used to get user input We’ve all used them before. For example, ever had to sign up for courses.
ITM © Port, Kazman1 ITM 352 More on Forms Processing.
Variables and ConstantstMyn1 Variables and Constants PHP stands for: ”PHP: Hypertext Preprocessor”, and it is a server-side programming language. Special.
HTML FORMS GET/POST METHODS. HTML FORMS HTML Forms HTML forms are used to pass data to a server. A form can contain input elements like text fields, checkboxes,
More on Variables Some related techniques. Header() function void header ( string $string [, bool $replace = true [, int $http_response_code ]] ) header()
Creating PHPs to Insert, Update, and Delete Data CS 320.
Sessions in PHP – Page 1 of 13CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: Sessions in PHP Reading: Williams.
Web Database Programming Week 7 Session Management & Authentication.
ITM © Port, Kazman1 ITM 352 More on Forms Processing.
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.
Sessions and Cookies State Management, Cookies, Sessions, Hidden Fields SoftUni Team Technical Trainers Software University
>> PHP: Insert Query & Form Processing. Insert Query Step 1: Define Form Variables Step 2: Make DB Connection Step 3: Error Handling Step 4: Define the.
ECMM6018 Enterprise Networking for Electronic Commerce Tutorial 7
PHP Error Handling & Reporting. Error Handling Never allow a default error message or error number returned by the mysql_error() and mysql_errno() functions.
Fundamentals of Web DevelopmentRandy Connolly and Ricardo HoarFundamentals of Web DevelopmentRandy Connolly and Ricardo Hoar Fundamentals of Web DevelopmentRandy.
How to maintain state in a stateless web Shirley Cohen
Various Notes on PHP Several useful tidbits not discussed in class.
Sessions Brendan Knight A visitor accessing your web site is assigned a unique id. This id links to specific data that remains on the server. Sessions.
PHP-language, sessions Teppo Räisänen Principal Lecturer Oulu University of Applied Sciences School of Business and Information Management
PHP and Sessions. Session – a general definition The GENERAL definition of a session in the “COMPUTER WORLD” is: The interactions (requests and responses)
Basic ActionScript and PHP Cis 126. Getting Started set up a basic folder structure so we can keep our files organized. Mirror this structure on your.
Creating Databases applications for the Web: week 2 Basic HTML review, forms HW: Identify unique source for asp, php, Open Source, MySql, Access.
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.
PHP Syntax You cannot view the PHP source code by selecting "View source" in the browser - you will only see the output from the PHP file, which is plain.
PHP Form Processing * referenced from
JavaScript Introduction and Background. 2 Web languages Three formal languages HTML JavaScript CSS Three different tasks Document description Client-side.
Web Page Designing With Dreamweaver MX\Session 1\1 of 9 Session 3 PHP Advanced.
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.
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.
Unit 4 Working with data. Form Element HTML forms are used to pass data to a server. A form can contain input elements like text fields, checkboxes, radio-buttons,
PHP – Hypertext Preprocessor.
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.
Web Systems Development (CSC-215)
PHP-II.
[Based in part on SWE 432 and SWE 632 materials by Jeff Offutt, GMU]
Presentation transcript:

1 CS428 Web Engineering Lecture 22 Building Dynamic Web pages (PHP - V)

There are three ways that we get data from our users on the web. User can provide information to server through three ways. URL’s/LinksGET FormsPOST CookiesCOOKIE INTERACTING WITH USER

EXAMPLE One or Multiple values from URL, & is use to separate values. Firstpage.php Second Page Secondpage.php <?php print_r($_GET); $id = $_GET[‘id’]; $name = $_GET[‘name’]; echo “ ”. $id. “: {$name} ”; ?> If we want multiple key pair values, then we separate one value with other through &.

urlencode() What if the & is included in the name. we could come with some kind of string that we passes &, % # sign. Firstpage.php &id=42”>Second Page Secondpage.php <?php print_r($_GET); $id = $_GET[‘id’]; $name = $_GET[‘name’]; echo “ ”. $id. “: {name} ”; ?>

htmlspecialchars() Sometimes we generate HTML, we want to have HTML tag in a link. We can handle it through PHP. Firstpage.php <?php $linktext = “ second page”; ?> &id=42”> <?php echo htmlspecialchars($linktext); ?> When your web server read this code, then due to htmlspecialchars command, if in string we have HTML characters, it ignores it in-fact treat it simple plain text.

FORMS Forms.php Username: Password:

Process.php (we just want to display values back to our page) <?php $username = $_POST[‘username’]; $password = $_POST[‘password’]; echo “{$username}: {$password}”; ?>

COOKIE Another way to interact with our users in user’s browser is COOKIES. Cookies are very useful, putting data on user’s browser. Our web server make a request to their web browser to send back a cookie. Cookies are going to be access in the same way as POST. In cookies you will learn an additional thing the SET cookie.

COOKIE Whenever we read a cookie, its going to be a very good practice. "; echo "Value is: ". $_COOKIE[$cookie_name]; } ?>

SESSION Session is a file that store on web server. And in that file we can store whatever information we want. The way we find out which file belongs to which user is by using a cookie. So we set a special session cookie on their browser, and then we look for that cookie to find the place where file resides on our server. And then we look inside that file, to find the information stored in that session.

EXAMPLE We will go above the HTML and make sure the session start commands. <?php session_start(); $_SESSION[“username”] = “user”; $_SESSION[“password”] = “123456”; ?> …… <?php session_unset(); // remove all session variables session_destroy(); // destroy the session ?>

HEADER - EXAMPLE <?php // this is how you redirect a page header(“Location: basic.html”); exit; ?> …

INCLUDE Through include feature you may include another PHP file in our PHP. This is going to help us, do not repeat ourselves. That’s always a good thing. Includes.php <?php include(“header.php”); include(“side-bar.php”); include(“footer.php”); ?>

Now there is variation in include, there is also be using REQUIRE. <?php require(“config.php”); ?> Require do basically the same thing as Include does. But it throws an error, if file is not able to loaded for some reasons. Include try to load the file but it wouldn’t generate the error. We can handle with require whenever something like functions that is definitely going to be required. And use include whenever we are loading HTML or something that’s not absolutely essential. There is one last variation in include and require, which is require_once. <?php require_once(“included_func.php”); ?> REQUIRE