session 8: working with form inet academy open source web development
TRANSCRIPT
![Page 1: Session 8: Working with Form iNET Academy Open Source Web Development](https://reader035.vdocuments.site/reader035/viewer/2022070411/56649f485503460f94c6a338/html5/thumbnails/1.jpg)
Session 8: Working with Form
iNET Academy
Open Source Web Development
![Page 2: Session 8: Working with Form iNET Academy Open Source Web Development](https://reader035.vdocuments.site/reader035/viewer/2022070411/56649f485503460f94c6a338/html5/thumbnails/2.jpg)
Objectives
Bulding a Form and Accessing Form’s Values Types of Input & Validating Data Query the DB with form data Using Template
![Page 3: Session 8: Working with Form iNET Academy Open Source Web Development](https://reader035.vdocuments.site/reader035/viewer/2022070411/56649f485503460f94c6a338/html5/thumbnails/3.jpg)
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
![Page 4: Session 8: Working with Form iNET Academy Open Source Web Development](https://reader035.vdocuments.site/reader035/viewer/2022070411/56649f485503460f94c6a338/html5/thumbnails/4.jpg)
Accessing Submitted Form Values
Using
![Page 5: Session 8: Working with Form iNET Academy Open Source Web Development](https://reader035.vdocuments.site/reader035/viewer/2022070411/56649f485503460f94c6a338/html5/thumbnails/5.jpg)
Accessing Submitted Form Values (cont.) Use super global variables
$_GET[field] $_POST[field] $_REQUEST[field]
register_globals should be off
![Page 6: Session 8: Working with Form iNET Academy Open Source Web Development](https://reader035.vdocuments.site/reader035/viewer/2022070411/56649f485503460f94c6a338/html5/thumbnails/6.jpg)
Default Values
![Page 7: Session 8: Working with Form iNET Academy Open Source Web Development](https://reader035.vdocuments.site/reader035/viewer/2022070411/56649f485503460f94c6a338/html5/thumbnails/7.jpg)
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
![Page 8: Session 8: Working with Form iNET Academy Open Source Web Development](https://reader035.vdocuments.site/reader035/viewer/2022070411/56649f485503460f94c6a338/html5/thumbnails/8.jpg)
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
![Page 9: Session 8: Working with Form iNET Academy Open Source Web Development](https://reader035.vdocuments.site/reader035/viewer/2022070411/56649f485503460f94c6a338/html5/thumbnails/9.jpg)
Types of Input – Check boxes
Used to give users several different options Use input element with type=“checkbox” The name attribute The value attribute
![Page 10: Session 8: Working with Form iNET Academy Open Source Web Development](https://reader035.vdocuments.site/reader035/viewer/2022070411/56649f485503460f94c6a338/html5/thumbnails/10.jpg)
Types of Input – Radio Button
Give the user several choice but can choose only one value
![Page 11: Session 8: Working with Form iNET Academy Open Source Web Development](https://reader035.vdocuments.site/reader035/viewer/2022070411/56649f485503460f94c6a338/html5/thumbnails/11.jpg)
Types of Input - Hidden
The information of hidden fields is not visible to the users
![Page 12: Session 8: Working with Form iNET Academy Open Source Web Development](https://reader035.vdocuments.site/reader035/viewer/2022070411/56649f485503460f94c6a338/html5/thumbnails/12.jpg)
Types of Input - Selects
Present a list of options to the user
Attributes of the <select> 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 <option>
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
![Page 13: Session 8: Working with Form iNET Academy Open Source Web Development](https://reader035.vdocuments.site/reader035/viewer/2022070411/56649f485503460f94c6a338/html5/thumbnails/13.jpg)
Types of Input – Selects (cont.)
![Page 14: Session 8: Working with Form iNET Academy Open Source Web Development](https://reader035.vdocuments.site/reader035/viewer/2022070411/56649f485503460f94c6a338/html5/thumbnails/14.jpg)
Working with Multiple Values
![Page 15: Session 8: Working with Form iNET Academy Open Source Web Development](https://reader035.vdocuments.site/reader035/viewer/2022070411/56649f485503460f94c6a338/html5/thumbnails/15.jpg)
Working with Multiple Values (cont.)
![Page 16: Session 8: Working with Form iNET Academy Open Source Web Development](https://reader035.vdocuments.site/reader035/viewer/2022070411/56649f485503460f94c6a338/html5/thumbnails/16.jpg)
Validating Data
Always validate data getting from users Validating checkboxes, radio buttons and selects
![Page 17: Session 8: Working with Form iNET Academy Open Source Web Development](https://reader035.vdocuments.site/reader035/viewer/2022070411/56649f485503460f94c6a338/html5/thumbnails/17.jpg)
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
![Page 18: Session 8: Working with Form iNET Academy Open Source Web Development](https://reader035.vdocuments.site/reader035/viewer/2022070411/56649f485503460f94c6a338/html5/thumbnails/18.jpg)
Building a Feet-to-Meters Converter in PHP
![Page 19: Session 8: Working with Form iNET Academy Open Source Web Development](https://reader035.vdocuments.site/reader035/viewer/2022070411/56649f485503460f94c6a338/html5/thumbnails/19.jpg)
Building a Time-Zone Conversion Utility in PHP
![Page 20: Session 8: Working with Form iNET Academy Open Source Web Development](https://reader035.vdocuments.site/reader035/viewer/2022070411/56649f485503460f94c6a338/html5/thumbnails/20.jpg)
Building a Time-Zone Conversion Utility in PHP (cont.)
![Page 21: Session 8: Working with Form iNET Academy Open Source Web Development](https://reader035.vdocuments.site/reader035/viewer/2022070411/56649f485503460f94c6a338/html5/thumbnails/21.jpg)
Building a Time-Zone Conversion Utility in PHP (cont.)
![Page 22: Session 8: Working with Form iNET Academy Open Source Web Development](https://reader035.vdocuments.site/reader035/viewer/2022070411/56649f485503460f94c6a338/html5/thumbnails/22.jpg)
Query the Db with Form Data
![Page 23: Session 8: Working with Form iNET Academy Open Source Web Development](https://reader035.vdocuments.site/reader035/viewer/2022070411/56649f485503460f94c6a338/html5/thumbnails/23.jpg)
Query the Db with Form Data (cont.)
![Page 24: Session 8: Working with Form iNET Academy Open Source Web Development](https://reader035.vdocuments.site/reader035/viewer/2022070411/56649f485503460f94c6a338/html5/thumbnails/24.jpg)
Query the Db with Form Data (cont.)
![Page 25: Session 8: Working with Form iNET Academy Open Source Web Development](https://reader035.vdocuments.site/reader035/viewer/2022070411/56649f485503460f94c6a338/html5/thumbnails/25.jpg)
Query the Db with Form Data (cont.)
![Page 26: Session 8: Working with Form iNET Academy Open Source Web Development](https://reader035.vdocuments.site/reader035/viewer/2022070411/56649f485503460f94c6a338/html5/thumbnails/26.jpg)
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