Download presentation
Presentation is loading. Please wait.
Published byIris Alexina Underwood Modified over 6 years ago
1
Form Data (part 2) MIS 3502, Fall 2015 Jeremy Shafer Department of MIS
Fox School of Business Temple University 11/10/2015
2
Course Overview We are here. To do: MySQL
Weeks 6 & 7 HTML & CSS Weeks 1 & 2 PHP Weeks 3 – 5 PDO Week 8 & 9 To do: Organize your code with MVC (week 11) Work with forms (week 12) Use cookies and sessions (week 13)
3
Objectives (this last class and this one)
Use text boxes, password boxes, radio buttons, check boxes, drop-down lists, list boxes, and text areas to get input from the user. Use hidden fields to pass data to the web application when a form is submitted. Use the htmlspecialchars and nl2br functions to display user entries the way you want them displayed. Get this data in to (and out of) a database table
4
Last time we looked at check boxes …
5
Recall from last time…
6
Another (new) approach to dealing with multiple check boxes is to assign them a common name, followed by a pair of square brackets.
7
When checkboxes are named in this way, the filter_input function can then be used to extract those selected values into an array. Like this… This option properly encodes the square brackets “[“ and “]” This option forces the output of the filter_input function to be an array,
8
OK… now what? It’s time for a …
We have an array of user provided data. Now what do we do with it? Presenting that data again, one element at a time, implies some sort of loop. The next slides illustrate two different approaches. One using foreach and the other using for.
9
Looping through the array with foreach
The => operator separates the key from the value in this array element. So $key gets “0” and $value gets “pep” when this loop iterates.
10
Looping through the array with a “for” loop
You might find this approach easier to understand. It does, however, rely on a function that is new to you. The count function will return the number of elements in an array
11
Selection lists
12
Notice that we use “selected” here
Notice that we use “selected” here. If this were a checkbox or radio button, we would have used “checked”.
14
Time for an experiment…
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.