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.

Slides:



Advertisements
Similar presentations
PHP Form and File Handling
Advertisements

LIS651 lecture 0 forms Thomas Krichel
HTML Forms. collect information for passing to server- side processes built up from standard widgets –text-input, radio buttons, check boxes, option lists,
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.
CIS101 Introduction to Computing Week 08. Agenda Your questions JavaScript text Resume project HTML Project Six This week online Next class.
PHP and the Web: Session : 4. Predefined variables PHP provides a large number of predefined global variables to any script which it runs also called.
Video, audio, embed, iframe, HTML Form
Supplement Creating Forms. Objectives Show how forms are used How to create the Form element HTML elements used for creating input fields.
HTML Form Processing Learning Web Design – Chapter 9, pp Squirrel Book – Chapter 11, pp
Python and Web Programming
Session 2 Tables and forms in HTML Adapted by Sophie Peter from original document by Charlie Foulkes.
Tutorial 6 Forms Section A - Working with Forms in JavaScript.
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.
Chapter 9 Working with Forms. Principles of Web Design 2nd Ed. Chapter 9 2 Principles of Web Design Chapter 9 Objectives Understand how forms work Understand.
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.
INTRODUCTION TO WEB DEVELOPMENT AND HTML Lecture 07: Forms - Spring 2011.
1 Chapter 6 – Creating Web Forms and Validating User Input spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information.
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.
4-Sep-15 HTML Forms Mrs. Goins Web Design Class. Parts of a Web Form A Form is an area that can contain Form Control/Elements. Each piece of information.
1 Creating Web Forms in HTML Web forms collect information from customers Web forms include different control elements including: –Input boxes –Selection.
1 Forms A form is the usual way that information is gotten from a browser to a server –HTML has tags to create a collection of objects that implement this.
Chapter 6: Forms JavaScript - Introductory. Previewing the Product Registration Form.
© 2011 Delmar, Cengage Learning Chapter 9 Collecting Data with Forms.
Internet / Intranet Fall 2000 Class 7. Brandeis University Internet/Intranet Spring Class 7 Agenda Project / Homework Discussion Forms Validating.
Internet / Intranet CIS-536 Class 7. 2 HTML Forms A Method to Allow Users to Pass Information to a CGI Script Forms Allow Information to Be Entered Via:
XHTML Introductory1 Forms Chapter 7. XHTML Introductory2 Objectives In this chapter, you will: Study elements Learn about input fields Use the element.
Robinson_CIS_285_2005 HTML FORMS CIS 285 Winter_2005 Instructor: Mary Robinson.
CSC 2720 Building Web Applications HTML Forms. Introduction  HTML forms are used to collect user input.  The collected input is typically sent to a.
Chapter 8 Collecting Data with Forms. Chapter 8 Lessons Introduction 1.Plan and create a form 2.Edit and format a form 3.Work with form objects 4.Test.
Website Development with PHP and MySQL Saving Data.
LOGO FORMs in HTML CHAPTER 5 Eastern Mediterranean University School of Computing and Technology Department of Information Technology ITEC229 Client-Side.
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.
1 Chapter 4 – Breaking It Up: Functions spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science and Technology.
ITCS373: Internet Technology Lecture 5: More HTML.
CSC 2720 Building Web Applications Server-side Scripting with PHP.
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,
HTML Form and PHP IST Review of Previous Class HTML table and PHP array Winner is chosen randomly using rand() function.
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.
TJ 3043 – Web Application Development HTML Form. 2.0 Forms A form is the usual way to communicate information from a Web browser to a server HTML has.
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.
TJ 3043 – Web Application Development HTML Form. 2.0 Forms - A form is the usual way information is gotten from a browser to a server - HTML has tags.
Introduction To HTML Form Inputs Written By George Gimian.
+ 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.
1 HTML forms (cont.)
©SoftMooreSlide 1 Introduction to HTML: Forms ©SoftMooreSlide 2 Forms Forms provide a simple mechanism for collecting user data and submitting it to.
HTML Forms.
Week 10: HTML Forms HNDIT11062 – Web Development.
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.
Creating Forms on a Web Page. 2 Introduction  Forms allow Web developers to collect visitor feedback  Forms create an environment that invites people.
1 HTML forms (cont.)
HTML FORM AND PHP IST 210: Organization of Data IST210 1.
CSE 154 LECTURE 18: FORMS AND UPLOADING FILES. Exercise: Baby name web service JSON Modify our babynames.php service to produce its output as JSON. For.
HTML III (Forms) Robin Burke ECT 270. Outline Where we are in this class Web applications HTML Forms Break Forms lab.
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.
HTML Structure II (Form) WEEK 2.2. Contents Table Form.
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.
2440: 141 Web Site Administration Web Forms Instructor: Joseph Nattey.
How to Write Web Forms By Mimi Opkins.
Section 17.1 Section 17.2 Add an audio file using HTML
Introducing Forms.
PHP-II.
Presentation transcript:

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 and Technology Radford University

2 HTML Form Fields in this chapter, we look at how to read data from form fields on html documents buttons checkboxes hidden fields image maps lists passwords radio buttons reset button select (Menus) submit button text areas text fields

3 Handling Client Data Review an html document may contain a form. A form tag includes an action attribute, that specifies the server side script to send the form data to if method is post, the data will be accessed via the $_POST array, if method is get then the data will be in $_GET array. the $_REQUEST array holds data from both post and get. These are superglobal arrays.

4 html Form form tag form field examples --- Enter first name: Under

5 form Fields (cont.) Menu's and text area's can also be used collect data on an html form. Processing data. in php code from a text box $txt = $_POST["fn"]; from a check box, if a check box has been checked it's value will be included in the query string $chk1 = $_POST["chk1"]; $chk1's value will be "book1"

6 Getting data from RB's Under receiving code <?php $age = $_POST["age"]; What will $age value be if the first radio button is clicked?

7 Hidden Fields let's you store hidden data in html documents say you had a multi-form application, so the user fills out one form and clicks on submit. the server application collects the data and then wants to have the user enter more info. on a new form. hidden fields can be used to insert this data into the second form, so it will return when the submit button on the second form is clicked. when the second form is submitted, the data can be retrieved as you would for a text field

8 Password Form Fields In PHP these are nearly the same as text boxes. However, the characters the user enters into the text field are not echoed to the screen. Rather an asterisk is echoed so the password can not be read by casual viewers of the screen. it is read in php just like a text field. <? $password = $_POST["pass1"]; Note -- the password is not necessarily encrypted in the query string

9 Image Maps PHP supports html image maps, which are clickable images full of hot spots, although you work with them differently in php. to create an image map you use when the user clicks the map, the mouse location is sent to the server. $xloc = $_POST["imap_x"]; when you know where the map was clicked you can use that info. to take different actions

10 Uploading Files HTML forms can be used to upload files. Assume you wish to upload a file named message.txt and make this text available to the php server script Upload this file:

11 Reading Uploaded Files There's another superglobal array $_FILES, it gives you access to the uploaded file $_FILES['userfile']['name'] original name of the file from user $_FILES['userfile']['type'] MIME type of the file for example -- "text/plain" or "image/gif") $_FILES['userfile']['size'] size of the uploaded file in bytes $_FILES['userfile']['tmp_name'] temporary filename of the file in which the uploaded file was stored on the server when a file is uploaded, it's stored as a temporary file on the server, and you access using - $_FILES['userfile']['tmp_name']

12 Reading Uploaded Files (cont) We'll see more about reading and writing files in chapter 6, but briefly here's the method used to open and read an uploaded file "; } fclose ($handle); ?>

13 Form Buttons, Method 1 You may want have multiple buttons on an html form, the question how can you tell which button(s) was (were) clicked by the client First method, when a button is clicked on a form put a description in a hidden field, then read that field in the php server script. A javascript will have to be included in the html form … javascripts next slide

14 Buttons Method 1 the following javascript would have to be included in the html form document --the receiving script then reads the hidden field to determine which button was clicked

15 Buttons Method 2 The second method is to build multiple forms on one html document. One form for each button. Each button could then be built using a submit button (there can only be one submit button on a form). There would be a hidden field in each form that contains the name of the submit button for that form One php server script can be specified in the action attribute of each form. The identity of the button can be read in the php server script by reading the hidden field. Each hidden field can be preset with the name of the submit button in that form. The problem with this approach is that if there is extra data to be included on the form, it has to be on all three forms. So, this method is rarely used.

16 Buttons Method 3 You can pass data back to the server script by using the value attribute of the submit button. You still must use three different forms, each with a submit button with the same name. We still have three forms, but the hidden field on each form is not needed. Each submit button would have a different value, the string displayed on the face of the button. In the php server script we would access the value as in: "; ?> why could you use both the $_POST and the $_REQUEST super global arrays?

17 Class Exercise Build a three part form - the first document is a form that has a text field that calls one php server script. This script puts the contents of the text field into another form and asks the user to indicate how many times they want to concatenate that entry together. It calls a second php script. The second server script performs the concatenation and outputs back to the client the original string entered and the concatenated string. This script should contain a function that is called multiple times to do the concatenation, it should utilize a static variable.