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.

Slides:



Advertisements
Similar presentations
HTML Forms. collect information for passing to server- side processes built up from standard widgets –text-input, radio buttons, check boxes, option lists,
Advertisements

WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
23-Aug-14 HTML/XHTML Forms. 2 What are forms? is just another kind of XHTML/HTML tag Forms are used to create (rather primitive) GUIs on Web pages Usually.
24-Aug-14 HTML Forms. 2 What are forms? is just another kind of HTML tag HTML forms are used to create (rather primitive) GUIs on Web pages Usually the.
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.
Creating Web Page Forms. Objectives Describe how Web forms can interact with a server-based program Insert a form into a Web page Create and format a.
Tutorial 6 Working with Web Forms
Tutorial 6 Working with Web Forms. XP Objectives Explore how Web forms interact with Web servers Create form elements Create field sets and legends Create.
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.
Forms, Validation Week 7 INFM 603. Announcements Try placing today’s example in htdocs (XAMPP). This will allow you to execute examples that rely on PHP.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
CST JavaScript Validating Form Data with JavaScript.
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.
PHP Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
Advance Database Management Systems Lab no. 5 PHP Web Pages.
Web forms in PHP Forms Recap  Way of allowing user interaction  Allows users to input data that can then be processed by a program / stored in a back-end.
Brief Overview of Web Forms L. G. Piper Bunker Hill Community College 23 March 2011.
XP Tutorial 6New Perspectives on HTML and XHTML, Comprehensive 1 Creating Web Page Forms Designing a Product Registration Form Tutorial 6.
CO1552 Web Application Development HTML Forms. Websites can be made more interactive by providing facilities for users to provide data To get user entered.
PHP Forms and User Input The PHP $_GET and $_POST variables are used to retrieve information from forms, like user input.
INTERNET APPLICATION DEVELOPMENT For More visit:
1 Creating Web Forms in HTML Web forms collect information from customers Web forms include different control elements including: –Input boxes –Selection.
Lecture 6 – Form processing (Part 1) SFDV3011 – Advanced Web Development 1.
Forms and Form Controls Chapter What is a Form?
Lesson 13: Building Web Forms Introduction to Adobe Dreamweaver CS6 Adobe Certified Associate: Web Communication using Adobe Dreamweaver CS6.
Lecture 7 – Form processing (Part 2) SFDV3011 – Advanced Web Development 1.
XHTML Introductory1 Forms Chapter 7. XHTML Introductory2 Objectives In this chapter, you will: Study elements Learn about input fields Use the element.
CSC 2720 Building Web Applications HTML Forms. Introduction  HTML forms are used to collect user input.  The collected input is typically sent to a.
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
Website Development with PHP and MySQL Saving Data.
 Whether using paper forms or forms on the web, forms are used for gathering information. User enter information into designated areas, or fields. Forms.
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.
LOGO FORMs in HTML CHAPTER 5 Eastern Mediterranean University School of Computing and Technology Department of Information Technology ITEC229 Client-Side.
1 © Netskills Quality Internet Training, University of Newcastle HTML Forms © Netskills, Quality Internet Training, University of Newcastle Netskills is.
PHP2. PHP Form Handling The PHP $_GET and $_POST variables are used to retrieve information from forms, like user input. Name: Age:
76 © 1998, 1999, 2000 David T. Gray, Howard Duncan, Jane Kernan Frames When displaying information in a browser, it is sometimes useful to divide the display.
HTML : Forms, Frames Instructor: Mr. Ahmed Al Astal ITGD4104 Department Requirement for senior student University of Palestine Faculty of IT.
ITCS373: Internet Technology Lecture 5: More HTML.
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,
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.
Tutorial 6 Working with Web Forms. XP Objectives Explore how Web forms interact with Web servers Create form elements Create field sets and legends Create.
Tutorial 6 Working with Web Forms. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Explore how Web forms interact with.
1 HTML Forms
FORMS. Forms are used to receive information from the web surfer, such as: their name, address, credit card, etc. Form fields are objects that allow.
ITM © Port, Kazman1 ITM 352 More on Forms Processing.
Forms Collecting Data CSS Class 5. Forms Create a form Add text box Add labels Add check boxes and radio buttons Build a drop-down list Group drop-down.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 9 Key Concepts 1 Copyright © Terry Felke-Morris.
+ 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.
Copyright © Texas Education Agency, All rights reserved.1 Web Technologies Website Forms / Data Acquisition.
Tutorial 6 Working with Web Forms. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Explore how Web forms interact with.
Creating Web Page Forms COE 201- Computer Proficiency.
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. A form is simply an area that can contain form fields. Form fields are objects that allow the visitor to enter information - for example text.
Since you’ll need a place for the user to enter a search query. Every form must have these basic components: – The submission type defined with the method.
1 HTML forms (cont.)
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
Web Forms. Web Forms: A form allows our web visitors to submit information to us. Some examples uses for forms are to let the web user contact us, fill.
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.
Ashima Wadhwa Java Script And Forms. Introduction Forms: –One of the most common Web page elements used with JavaScript –Typical forms you may encounter.
2440: 141 Web Site Administration Web Forms Instructor: Joseph Nattey.
FORMS Explained By: Sarbjit Kaur.
Cookies BIS1523 – Lecture 23.
Introducing Forms.
HTML Forms and User Input
PHP-II.
Presentation transcript:

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 visitor and then use PHP to do process that information. In the classroom PCs the configuration has been implemented so that each PC does have a Web server software (Apache HTTP Server) of it’s own. All the HTML files must be saved to the directory C:\Program Files\Apache Group\Apache2\htdocs\YourPersonalFoulderNa me This means that will display the home page of the local web site.

Reading Data in Web Pages tMyn2 The PHP $_GET and $_POST variables are used to retrieve information from forms, like user input. The most important thing to notice when dealing with HTML forms and PHP is that any form element in an HTML page will automatically be available to your PHP scripts. The example below contains an HTML form with two text input fields and a submit button.

Reading Data in Web Pages tMyn3 Text fields are one line areas that allow the user to input text. The name setting adds an internal name to the field so the program that handles the form can identify the fields. The value setting defines what will appear in the box as the default value.

Reading Data in Web Pages tMyn4 When a visitor clicks a submit button, the form is sent to the address specified in the action setting of the tag. The name setting adds an internal name to the button so the program that handles the form doesn't confuse the button with the other fields. The value setting defines what is written on the button.

Reading Data in Web Pages tMyn5

Reading Data in Web Pages tMyn6 When a user fills out the form above and click on the submit button, the form data is sent to a PHP file, called “inputField.php": " inputField.php" looks like this:

Reading Data in Web Pages tMyn7

Reading Data in Web Pages tMyn8 Be sure to take notice the names of the form data names, as they represent the keys in the "$_POST" associative array. Next the output could be something like this:

Reading Data in Web Pages tMyn9

Reading Data in Web Pages tMyn10

Reading Data in Web Pages tMyn11 The built-in $_POST function is used to collect values from a form sent with method="post". Information sent from a form with the POST method is invisible to others and has no limits on the amount of information to send. Note: However, there is an 8 Mb max size for the POST method, by default (can be changed by setting the post_max_size in the php.ini file). When the user clicked the "Submit" button in the previous example, the URL looked like this: ing/inputField.phpThe. “inputField.php" file was able to use the $_POST function to collect form data (the names of the form fields will automatically be the keys in the $_POST array).

Reading Data in Web Pages tMyn12 Another way to get this information would be to create two new variables and set them equal to the values that have been "posted“:

Reading Data in Web Pages tMyn13

Reading Data in Web Pages tMyn14 When to use method="post" ? Information sent from a form with the POST method is invisible to others and has no limits on the amount of information to send. However, because the variables are not displayed in the URL, it is not possible to bookmark the page.

Reading Data in Web Pages tMyn15 The built-in $_GET function is used to collect values from a form sent with method="get". Information sent from a form with the GET method is visible to everyone (it will be displayed in the browser's address bar) and has limits on the amount of information to send (max. 100 characters). The get method passes the variables along to the “inputField2.php" web page by appending them onto the end of the URL.

Reading Data in Web Pages tMyn16

Reading Data in Web Pages tMyn17

Reading Data in Web Pages tMyn18

Reading Data in Web Pages tMyn19

Reading Data in Web Pages tMyn20 When the user clicked the "Submit" button, the URL sent to the server looked something like this: ing/inputField2.php?fName=Kirsi&sName=Taiv alantti. The question mark "?" tells the browser that the following items are variables. The “inputField.php" file was able to use the $_GET function to collect form data (the names of the form fields will automatically be the keys in the $_GET array).

Reading Data in Web Pages tMyn21 When to use method="get" ? When using method="get" in HTML forms, all variable names and values are displayed in the URL. Note: Because of the above behavior this method should not be used when sending passwords or other sensitive information! However, because the variables are displayed in the URL, it is possible to bookmark the page. This can be useful in some cases. Note: The get method is not suitable for large variable values; the value cannot exceed 100 characters.

Reading Data in Web Pages tMyn22 The PHP $_REQUEST Function The PHP built-in $_REQUEST function contains the contents of both $_GET, $_POST, and $_COOKIE. The $_REQUEST function can be used to collect form data sent with both the GET and POST methods.

Reading Data in Web Pages tMyn23

Reading Data in Web Pages tMyn24

Reading Data in Web Pages tMyn25

Reading Data in Web Pages tMyn26

Reading Data in Web Pages tMyn27 Next example deals with Drop-Down Menu, only one item can be selected. The name setting adds an internal name to the field so the program that handles the form can identify the fields. The value setting defines what will be submitted if the item is selected. This is not always the same as what it says in the menu. name = value information will be sent to the script (if the value attribute is used – otherwise the text displayed in the menu will be transmitted):

Reading Data in Web Pages tMyn28

Reading Data in Web Pages tMyn29

Reading Data in Web Pages tMyn30

Reading Data in Web Pages tMyn31

Reading Data in Web Pages tMyn32 Again an example with Drop-Down Menu, now several items can be selected. The multiple setting will allow for multiple selections if present. Here we must give the control the name of an array, not just a name.

Reading Data in Web Pages tMyn33

Reading Data in Web Pages tMyn34

Reading Data in Web Pages tMyn35

Reading Data in Web Pages tMyn36

Reading Data in Web Pages tMyn37 Radio buttons are used when you want to let the visitor select one - and just one - option from a set of alternatives. If more options are to be allowed at the same time you should use check boxes instead. The name setting tells which group of radio buttons the field belongs to. When you select one button, all other buttons in the same group are unselected. If you couldn't define which group the current button belongs to, you could only have one group of radio buttons on each page. The value setting defines what will be submitted if checked.

Reading Data in Web Pages tMyn38

Reading Data in Web Pages tMyn39

Reading Data in Web Pages tMyn40

Reading Data in Web Pages tMyn41

Reading Data in Web Pages tMyn42 Next example is only slightly modified compared to the previous one:

Reading Data in Web Pages tMyn43

Reading Data in Web Pages tMyn44

Reading Data in Web Pages tMyn45

Reading Data in Web Pages tMyn46

Reading Data in Web Pages tMyn47 Check boxes are used when you want to let the visitor select one or more options from a set of alternatives. The name setting adds an internal name to the field so the program that handles the form can identify the fields. The value setting defines what will be submitted if checked.

Reading Data in Web Pages tMyn48

Reading Data in Web Pages tMyn49

Reading Data in Web Pages tMyn50

Reading Data in Web Pages tMyn51

Reading Data in Web Pages tMyn52

Reading Data in Web Pages tMyn53 A minor modification to the previous one, let us give the name setting the name of an array:

Reading Data in Web Pages tMyn54

Reading Data in Web Pages tMyn55

Reading Data in Web Pages tMyn56

Reading Data in Web Pages tMyn57

Reading Data in Web Pages tMyn58

Reading Data in Web Pages tMyn59 Text areas are text fields that can span several lines. Unlike most other form fields, text areas are not defined with an tag. Instead you enter a tag where you want the text area to start and a closing tag where you want the area to end. Everything written between these tags will be presented in the text area box. The name setting adds an internal name to the field so the program that handles the form can identify the fields.

Reading Data in Web Pages tMyn60

Reading Data in Web Pages tMyn61

Reading Data in Web Pages tMyn62

Reading Data in Web Pages tMyn63

Reading Data in Web Pages tMyn64 Password fields are similar to text fields. The difference is that what is entered into a password field shows up as dots on the screen. This is, of course, to prevent others from reading the password on the screen. The name setting adds an internal name to the field so the program that handles the form can identify the fields.

Reading Data in Web Pages tMyn65

Reading Data in Web Pages tMyn66

Reading Data in Web Pages tMyn67

Reading Data in Web Pages tMyn68 The previous example checks the given password against the password, which is “ thisIsWhatIExpected ” in this case, and if it matches, display a welcome page to the user. On the other hand, if password the user entered is not right, you can display an error page – note how the password1.php script mixes HTML and PHP.

Reading Data in Web Pages tMyn69

Reading Data in Web Pages tMyn70

Reading Data in Web Pages tMyn71 If you do not enter the right password:

Reading Data in Web Pages tMyn72

Reading Data in Web Pages tMyn73

Reading Data in Web Pages tMyn74 Hidden fields are similar to text fields, with one very important difference! The difference is that the hidden field does not show on the page. Therefore the visitor can't type anything into a hidden field, which leads to the purpose of the field: to submit information that is not entered by the visitor. The name setting adds an internal name to the field so the program that handles the form can identify the fields. The value setting defines what will be sent once the form is submitted.

Reading Data in Web Pages tMyn75

Reading Data in Web Pages tMyn76

Reading Data in Web Pages tMyn77

Reading Data in Web Pages tMyn78

Reading Data in Web Pages tMyn79 Putting it all in one page So far, the applications we have developed have relied on an HTML start page that connects to a PHP page. However, it can all be handled with one PHP page. Next is an example, which asks the name of the user. The name will be stored in the $_REQUEST array under the name “myName”. That means that if data is waiting for you in the $_REQUEST array under the name “myName”, you should display that data. If data is not waiting for you, you should display the welcome page that asks for the name.

Reading Data in Web Pages tMyn80 You can check if data is waiting for you with the PHP isset() function, which returns TRUE if an array element exists

Reading Data in Web Pages tMyn81

Reading Data in Web Pages tMyn82

Reading Data in Web Pages tMyn83

Reading Data in Web Pages tMyn84