Download presentation
Presentation is loading. Please wait.
Published byClarence Nicholson Modified over 9 years ago
1
Session 8: Working with Form iNET Academy Open Source Web Development
2
Objectives Bulding a Form and Accessing Form’s Values Types of Input & Validating Data Query the DB with form data Using Template
3
Building a Form Every form must have three basic components The submission type defined with the method keyword One or more input elements defined with the input tag The destination to go to when submitted defined with the action keyword
4
Accessing Submitted Form Values Using
5
Accessing Submitted Form Values (cont.) Use super global variables $_GET[field] $_POST[field] $_REQUEST[field] register_globals should be off
6
Default Values
7
Types of Input – Text boxes Used to capture strings from the user The name attribute: used to reference to the value The size attribute: specifies the length of the text box The maxlength attribute: determines the maximum number of characters
8
Types of Input – Text areas A text area is defined using the text area element The name attribute The cols attribute: specifies how many character columns to create The rows attribute: specifies how many rows to create
9
Types of Input – Check boxes Used to give users several different options Use input element with type=“checkbox” The name attribute The value attribute
10
Types of Input – Radio Button Give the user several choice but can choose only one value
11
Types of Input - Hidden The information of hidden fields is not visible to the users
12
Types of Input - Selects Present a list of options to the user Attributes of the The name attribute The size attribute: specifies how many lines of the list appear in the browser window The multiple attribute: allow the user to select more than one item from the list Attributes of the The selected attribute specifies a default selection The value attribute specifies a value that is different from the label of the option. If no value is specidied, the label is used as the value
13
Types of Input – Selects (cont.)
14
Working with Multiple Values
15
Working with Multiple Values (cont.)
16
Validating Data Always validate data getting from users Validating checkboxes, radio buttons and selects
17
Validating Data (cont.) Validating text boxes and text areas Decide which information is valid and which is not Check for empty values Check for other conditions like @ in a email field
18
Building a Feet-to-Meters Converter in PHP
19
Building a Time-Zone Conversion Utility in PHP
20
Building a Time-Zone Conversion Utility in PHP (cont.)
22
Query the Db with Form Data
23
Query the Db with Form Data (cont.)
26
Practice In this practice, you will Write an program to search for a book based on only one of three following condition Author Title Price
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.