Geek Austin PHP Class - Session 3
-
Upload
jimbojsb -
Category
Technology
-
view
970 -
download
0
description
Transcript of Geek Austin PHP Class - Session 3
![Page 1: Geek Austin PHP Class - Session 3](https://reader030.fdocuments.in/reader030/viewer/2022013011/553acab54a7959eb2d8b45cc/html5/thumbnails/1.jpg)
Beginning PHPSession #3
November 30, 2010
Josh Butts
![Page 2: Geek Austin PHP Class - Session 3](https://reader030.fdocuments.in/reader030/viewer/2022013011/553acab54a7959eb2d8b45cc/html5/thumbnails/2.jpg)
Agenda
•Application organization
•Superglobals
•Forms, GET and POST
•Sessions
•Basic Dates & Times
![Page 3: Geek Austin PHP Class - Session 3](https://reader030.fdocuments.in/reader030/viewer/2022013011/553acab54a7959eb2d8b45cc/html5/thumbnails/3.jpg)
Superglobals
•Available in every scope, no matter what
•Automatically set by PHP
•Arrays
•#1 attack vector
![Page 4: Geek Austin PHP Class - Session 3](https://reader030.fdocuments.in/reader030/viewer/2022013011/553acab54a7959eb2d8b45cc/html5/thumbnails/4.jpg)
$_GET
•Associative array corresponding to the query string
•Use this for READ ONLY data
![Page 5: Geek Austin PHP Class - Session 3](https://reader030.fdocuments.in/reader030/viewer/2022013011/553acab54a7959eb2d8b45cc/html5/thumbnails/5.jpg)
$_POST
•Associative array that corresponds to form POSTs
•Use this when you will be modifying something on the server
•Array keys correspond to HTML input names
![Page 6: Geek Austin PHP Class - Session 3](https://reader030.fdocuments.in/reader030/viewer/2022013011/553acab54a7959eb2d8b45cc/html5/thumbnails/6.jpg)
$_POST
![Page 7: Geek Austin PHP Class - Session 3](https://reader030.fdocuments.in/reader030/viewer/2022013011/553acab54a7959eb2d8b45cc/html5/thumbnails/7.jpg)
$_SERVER
•Contains environment information
•Contains information about the HTTP request used to access this page
![Page 8: Geek Austin PHP Class - Session 3](https://reader030.fdocuments.in/reader030/viewer/2022013011/553acab54a7959eb2d8b45cc/html5/thumbnails/8.jpg)
Sessions
•Keep track of info about your user
•Each user gets an ID and a cookie
•Actual session data is stored on the server
•Low security but easy
![Page 9: Geek Austin PHP Class - Session 3](https://reader030.fdocuments.in/reader030/viewer/2022013011/553acab54a7959eb2d8b45cc/html5/thumbnails/9.jpg)
Using Sessions
•Call session_start()
•Use $_SESSION superglobal to get and set data
•Sessions expire when the browser is closed (you can configure this)
![Page 10: Geek Austin PHP Class - Session 3](https://reader030.fdocuments.in/reader030/viewer/2022013011/553acab54a7959eb2d8b45cc/html5/thumbnails/10.jpg)
Session Demo
![Page 11: Geek Austin PHP Class - Session 3](https://reader030.fdocuments.in/reader030/viewer/2022013011/553acab54a7959eb2d8b45cc/html5/thumbnails/11.jpg)
Dates & Times•Dates & times are relative to the
timezone of your server
•time() - Unix Timestamp
•date() - format a date string
•mktime() - get a specific unix timestamp
•strtotime() - convert an english-ish string to a timestamp
![Page 12: Geek Austin PHP Class - Session 3](https://reader030.fdocuments.in/reader030/viewer/2022013011/553acab54a7959eb2d8b45cc/html5/thumbnails/12.jpg)
extract()
•Registers all the keys in an array as variables
•Use extreme with caution
![Page 13: Geek Austin PHP Class - Session 3](https://reader030.fdocuments.in/reader030/viewer/2022013011/553acab54a7959eb2d8b45cc/html5/thumbnails/13.jpg)
Let’s buildsomething real