Class05 How to get data from a form

Slides:



Advertisements
Similar presentations
Murach’s C# 2010, C6 © 2010, Mike Murach & Associates, Inc.Slide 1.
Advertisements

Murach’s C# 2010, C3 © 2010, Mike Murach & Associates, Inc.Slide 1.
Murach's C# 2012, C3© 2013, Mike Murach & Associates, Inc.Slide 1.
Murach's PHP and MySQL, C2© 2010, Mike Murach & Associates, Inc.Slide 1.
Murach's MySQL, C2© 2012, Mike Murach & Associates, Inc.Slide 1.
Murach's PHP and MySQL, C2© 2010, Mike Murach & Associates, Inc.Slide 1.
Murach’s C# 2010, C1© 2010, Mike Murach & Associates, Inc.Slide 1.
© 2013, Mike Murach & Associates, Inc.
Murach’s C# 2010, C4 © 2010, Mike Murach & Associates, Inc.Slide 1.
Murach’s C# 2010, C4 © 2010, Mike Murach & Associates, Inc.Slide 1.
Murach's C , C4 © 2009, Mike Murach & Associates, Inc. Slide 1 © 2009, Mike Murach & Associates, Inc.Slide 1.
Murach's PHP and MySQL, C4© 2010, Mike Murach & Associates, Inc.Slide 1.
Murach's PHP and MySQL, C4© 2010, Mike Murach & Associates, Inc.Slide 1.
Class11 Introduction to relational databases and MySQL MIS 3501, Fall 2015 Brad Greenwood, PhD MBA Department of MIS Fox School of Business Temple University.
Class06 Conditional Statements MIS 3501, Fall 2015 Brad Greenwood, PhD MBA Department of MIS Fox School of Business Temple University 9/10/2015 © 2014,
Class03 Introduction to Web Development (Hierarchy and the IDE) MIS 3501, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
Form Data (part 2) MIS 3502, Fall 2015 Brad N Greenwood, PhD Department of MIS Fox School of Business Temple University 11/10/2015 Slide 1.
Form Data (part 1) MIS 3502, Fall 2015 Brad Greenwood, PhD Department of MIS Fox School of Business Temple University 11/10/2015.
Class07 PHP: loops and includes MIS 3501, Fall 2015 Brad Greenwood, PhD MBA Department of MIS Fox School of Business Temple University 9/15/2015.
Class05 How to get data from a form MIS 3501, Fall 2015 Brad N Greenwood, PhD MBA Department of MIS Fox School of Business Temple University 9/8/2015.
Sessions and cookies MIS 3501, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 4/12/2016.
Introduction to JavaScript MIS 3502, Fall 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 9/29/2016.
PDO Database Connections
© 2010, Mike Murach & Associates, Inc.
Class03 Introduction to Web Development (Hierarchy and the IDE)
Brad N Greenwood, PhD MBA
Sessions and cookies MIS 3501 Jeremy Shafer Department of MIS
Form Data (part 2) MIS 3502, Fall 2015 Jeremy Shafer Department of MIS
Organize your code with MVC
PHP: includes MIS 3501 Jeremy Shafer Department of MIS
Form Data (part 1) MIS 3502, Fall 2015 Jeremy Shafer Department of MIS
Class07 PHP: loops and includes
© 2010, Mike Murach & Associates, Inc.
How to get data from a form
© 2010, Mike Murach & Associates, Inc.
PDO Database Connections: Getting data out of the database
© 2010, Mike Murach & Associates, Inc.
© 2010, Mike Murach & Associates, Inc.
© 2010, Mike Murach & Associates, Inc.
© 2010, Mike Murach & Associates, Inc.
© 2010, Mike Murach & Associates, Inc.
© 2010, Mike Murach & Associates, Inc.
PDO Database Connections: Getting data out of the database
© 2010, Mike Murach & Associates, Inc.
Form Data (part 2) MIS 3501 Jeremy Shafer Department of MIS
Organize your code with MVC
© 2010, Mike Murach & Associates, Inc.
© 2010, Mike Murach & Associates, Inc.
© 2010, Mike Murach & Associates, Inc.
Introduction to relational databases and MySQL
Sessions and cookies (part 1)
© 2015, Mike Murach & Associates, Inc.
© 2015, Mike Murach & Associates, Inc.
© 2015, Mike Murach & Associates, Inc.
Form Data (part 2) MIS 3501 Jeremy Shafer Department of MIS
Class07 PHP: loops MIS 3501 Jeremy Shafer Department of MIS
Class08 Using the Documentation
MySQL Backup, Transfer and Restore
© 2010, Mike Murach & Associates, Inc.
Sessions and cookies MIS 3501 Jeremy Shafer Department of MIS
Class11 Introduction to relational databases and MySQL
Form Data (part 1) MIS3501 Jeremy Shafer Department of MIS
© 2015, Mike Murach & Associates, Inc.
© 2010, Mike Murach & Associates, Inc.
© 2015, Mike Murach & Associates, Inc.
© 2010, Mike Murach & Associates, Inc.
© 2010, Mike Murach & Associates, Inc.
Presentation transcript:

Class05 How to get data from a form MIS 3501, Fall 2015 Jeremy Shafer Department of MIS Fox School of Business Temple University 9/8/2015

Course Overview We are here. MySQL To do: HTML & CSS Weeks 1 & 2 PHP Weeks 3 & 4 PDO Week 7 MySQL Weeks 5 & 6 We are here. To do: Organize your code with MVC (week 8) Debug your code (week 9) Work with forms (week 10) Use arrays (week 11 & 12) Use sessions (week 13)

What is the role of these delimiters? Discuss: What is the role of these delimiters? Notice how each PHP statement ends with a semicolon. Why? © 2014, Mike Murach & Associates, Inc.

What is the significance of Discuss: What is the significance of first_name and last_name ??? © 2014, Mike Murach & Associates, Inc.

© 2014, Mike Murach & Associates, Inc. Discuss: What does echo do? © 2014, Mike Murach & Associates, Inc.

© 2014, Mike Murach & Associates, Inc. If I were to “View Source Code” here in the browser, would it be the same or different from the previous slide? © 2014, Mike Murach & Associates, Inc.

© 2014, Mike Murach & Associates, Inc. Discuss: Comments don’t change the way the code works. So why do we bother with comments? © 2014, Mike Murach & Associates, Inc.

© 2014, Mike Murach & Associates, Inc.

What about these things? Discuss: What about these things? What are they? © 2014, Mike Murach & Associates, Inc.

© 2014, Mike Murach & Associates, Inc.

© 2014, Mike Murach & Associates, Inc.

© 2014, Mike Murach & Associates, Inc.

Things you can do with variables <?php // things you can do with variables $a = 20; // assignment of values $b = 10; $c = $a + $b; // addition echo $c; // 30 echo "<br>"; $c = $a - $b; // subtraction echo $c; // 10 $c = $a * $b; // multiplication echo $c; // 200 © 2014, Mike Murach & Associates, Inc.

Things you can do with variables (2) // continued from previous slide $c = $a / $b; // division echo $c; // 2 echo "<br>"; $c = $a . $b; // concatenation echo $c; // 2010 // WHAT ABOUT THIS? $c = $a . "%"; echo $c; ?> © 2014, Mike Murach & Associates, Inc.

© 2014, Mike Murach & Associates, Inc. When working with HTML forms, we have two techniques for transferring user supplied data to a PHP page. Those techniques are: GET and POST. PHP HTML FORM Method=“POST” Method=“GET” © 2014, Mike Murach & Associates, Inc.

© 2014, Mike Murach & Associates, Inc.

© 2014, Mike Murach & Associates, Inc.

© 2014, Mike Murach & Associates, Inc.

© 2014, Mike Murach & Associates, Inc.

© 2014, Mike Murach & Associates, Inc. Instead of accessing the $_POST array directly, there is now a function called filter_input(). This new approach offers some advantages that we will investigate next class. For now, it is enough to know that we can replace code that looks like this: $last_name = $_POST['last_name']; With this: $last_name = filter_input(INPUT_POST,'last_name‘); © 2014, Mike Murach & Associates, Inc.

© 2014, Mike Murach & Associates, Inc.