Passing variables between pages

Slides:



Advertisements
Similar presentations
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.
Advertisements

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.
Video, audio, embed, iframe, HTML Form
Chapter 31 Basic Form-Processing Techniques JavaServer Pages By Xue Bai.
Forms Review. 2 Using Forms tag  Contains the form elements on a web page  Container tag tag  Configures a variety of form elements including text.
Validating user input Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
Database Connectivity in PHP Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
Introduction to PHP (Part-1) Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
Uploading Files. Why? By giving a user the option to upload a file you are creating an interactive page You can enable users have a greater web experience.
File uploading in PHP Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
MS3304: Week 4 PHP & HTML Forms. Overview HTML Forms elements refresher Sending data to a script via an HTML form –The post vs. get methods –Name value.
Unit 7 – Working with Forms 1. Creating a form 2. Accessing the submitted data 3. Common operations on forms.
Advance Database Management Systems Lab no. 5 PHP Web Pages.
_______________________________________________________________________________________________________________ PHP Bible, 2 nd Edition1  Wiley and the.
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.
Deleting and Updating Records in MySQL using PHP Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
1 Creating Web Forms in HTML Web forms collect information from customers Web forms include different control elements including: –Input boxes –Selection.
HTML - Forms By Joaquin Vila, Ph.D.. Form Tag The FORM tag specifies a fill-out form within an HTML document. More than one fill-out form can be in a.
History, Navigator, Screen and Form Objects Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 1.
CSC 2720 Building Web Applications HTML Forms. Introduction  HTML forms are used to collect user input.  The collected input is typically sent to a.
Adding Image, audio and video files to web pages Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
© Anselm Spoerri Web Design Information Visualization Course Prof. Anselm Spoerri
Website Development with PHP and MySQL Saving Data.
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.
1 © Netskills Quality Internet Training, University of Newcastle HTML Forms © Netskills, Quality Internet Training, University of Newcastle Netskills is.
HTML - Forms By Joaquin Vila, Ph.D.. Form Tag The FORM tag specifies a fill-out form within an HTML document. More than one fill-out form can be in a.
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,
CHAPTER 7 Form & PHP. Introduction All of the following examples in this section will require two web pages. The first page retrieves information posted.
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.
Retrieving data from MySQL using PHP Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 9 Key Concepts 1 Copyright © Terry Felke-Morris.
Session 8: Working with Form iNET Academy Open Source Web Development.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 9 Key Concepts 1 Copyright © Terry Felke-Morris.
Forms Overview, Query string, Submitting arrays, PHP & HTML, Input types, Redirecting the user Mario Peshev Technical Trainer Software.
+ FORMS HTML forms are used to pass data to a server. begins and ends a form Forms are made up of input elements Every input element has a name and value.
©SoftMooreSlide 1 Introduction to HTML: Forms ©SoftMooreSlide 2 Forms Forms provide a simple mechanism for collecting user data and submitting it to.
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.
HTML FORMS Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan. 1.
1 Committed to Shaping the Next Generation of IT Experts. 03: Links and Forms HTML.
HTML 5 Form elements Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
HTML DOM Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 1.
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.
HTML Links and navigation Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
Lesson 5 Introduction to HTML Forms. Lesson 5 Forms A form is an area that can contain form elements. Form elements are elements that allow the user to.
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,
FORMS Explained By: Jasdeep Kaur. Lecturer, Department of Computer Application, PGG.C.G., Sector: 42, Chandigarh.
Informatics Computer School CS114 Web Publishing HTML Lesson 4.
PHP – Hypertext Preprocessor.
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
How to Write Web Forms By Mimi Opkins.
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
CS3220 Web and Internet Programming HTML Tables and Forms
Web Design and Development
FORMS Explained By: Sarbjit Kaur.
PHP FORM HANDLING Post Method
Basic Contact Form user sends an
Validation and Building Small Apps
Introduction to Web programming
Simple PHP application
HTML Forms and User Input
Dr. John P. Abraham Professor UTRGV eCommerce CSCI 6314
Web Systems Development (CSC-215)
Web Development & Design Foundations with H T M L 5
Forms, cont’d.
Web Programming Language
SESSION TRACKING BY DINESH KUMAR.R.
PHP Lecture 11 Kanida Sinmai
PHP-II.
Web Forms.
Presentation transcript:

Passing variables between pages Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.

Summary of the previous lecture Operators in PHP Conditional Statements in PHP Looping Statements Arrays in PHP Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan. Department of Computer Science, CIIT Islamabad.

Outline Super Global variables Passing form data Passing data with sessions Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan. Department of Computer Science, CIIT Islamabad.

1. Passing form data Forms provide a mean of submitting information from the client to the server We can create HTML forms using <form> tag Method and action are the most common attributes of <form> Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.

1. Passing form data… action - gives the URL of the application that is to receive and process the forms data method - sets the HTTP method that the browser uses to send the form's data to the server for processing most common methods are POST or GET Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.

1. Passing form data… Get method : all form data is encoded into the URL, appended the action URL as query string parameters Asad asd@gmail.com submit Value entered by user Action page name Input field name Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.

1. Passing form data… Post method: form data appears within the message body of the HTTP request Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.

1.1 Super Global Variables PHP automatically makes few variables available in your program These are array variables and can be accessed by name These variables are called super-global variables because they can be accessed without regard to scope Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.

1.1 Super Global Variables… $_GET: contains all the query string variables that were attached to the URL $_POST: contains all the submitted form variables and their data Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.

1.1 Super Global Variables… <body> <form method=“get” action=“action.php”> <input type=“text” name=“name”> <input type=“text” name=“email”> <input type=“submit”> </form> </body> Asad asd@gmail.com submit name email $_GET Asad asd@gmail.com Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.

1.1 Super Global Variables… <body> <form method=“post”> <input type=“text” name=“name”> <input type=“text” name=“email”> <input type=“submit”> </form> </body> Asad asd@gmail.com submit $_POST Asad asd@gmail.com name email Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.

1.2 Accessing form data on action page name email $_GET Asad asd@gmail.com Ation.php <?php $name = $_GET[‘name’]; $email = $_GET[‘email’]; ?> Asad asd@gmail.com submit Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.

1.2 Accessing form data on action page… name email $_POST Asad asd@gmail.com Ation.php <?php $name = $_POST[‘name’]; $email = $_POST[‘email’]; ?> Asad asd@gmail.com submit Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.

2. Passing text field data Post Method Text field Text field name Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.

2. Passing text field data… Data is received Display a message Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.

2. Passing text field data… We are at form page We are on action page Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.

2. Passing hidden field data… Hidden value Field name Accessing hidden value Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.

2. Passing hidden field data… Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.

2.3 Getting value from checkbox name value label Getting value of ‘C’ Getting value of ‘VB’ Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.

2.3 Getting value from checkbox… Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.

2.3 Getting value from checkbox… Checking for value of C Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.

2.4 Getting value from radio button Same name Value is set Value is not set Getting value of radio Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.

2.4 Getting value from radio button… Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.

2.5 Getting value from select list Name of the list Option and value Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.

2.5 Getting value from select list… Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.

3. Passing variables using sessions A session is basically a temporary set of variables that exists only until the browser has shut down $_SESSION: represents data available to a PHP script that has previously been stored in a session Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.

3. Passing variables using sessions… name email $_SESSION Asad asd@gmail.com First page <?php $_SESSION[‘name ‘] =‘Asad’; ?> 2nd page <?php echo $_SESSION[‘name ‘]; $_SESSION[‘email ‘] =‘asd@gmail.com’; ?> nth page <?php echo $_SESSION[‘name ‘]; echo $_SESSION[‘email ‘]; ?> ……. Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.

3. Passing variables using sessions session_start()- is used to start a session $_SESSION[‘variable_name’]- is used to store data in session variable session_destroy()- is used to destroy a session unset($_SESSION[‘variable_name’])- is used to unset a specific variable Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.

3. Passing variables using sessions… Session starts Session variable is created Link to the next page Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.

3. Passing variables using sessions… Session starts Session variable is accessed link Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.

3. Passing variables using sessions… Session variable’s value Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.

3. Passing variables using sessions… Session is destroyed Session is accessed Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.

3. Passing variables using sessions… Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.

Summary Super global variables Passing data with forms Using session variables Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.

References Chapter 2, “Beginning PHP6,Apache,Mysql web development” by Matt Doyle, Wrox publishers, 2009, ISBN: 0470413964 Chapter 13, “Beginning PHP and MySQL” by W. Jason Gilmore, Apress publisher, 4th edition; 2010, ISBN-13 (electronic): 978-1-4302-3115-8. Basharat Mahmood, Department of Computer Science,CIIT,Islamabad,Pakistan.