INFO 344 Web Tools And Development CK Wang University of Washington Spring 2014.

Slides:



Advertisements
Similar presentations
JQuery MessageBoard. Lets use jQuery and AJAX in combination with a database to update and retrieve information without refreshing the page. Here we will.
Advertisements

Introduction to R Brody Sandel. Topics Approaching your analysis Basic structure of R Basic programming Plotting Spatial data.
Use-Cases.
9/9/2005 Developing "Secure" Web Applications 1 Methods & Concepts for Developing “Secure” Web Applications Peter Y. Hammond, Developer Wasatch Front Regional.
Nov 10, Fall 2006IAT 8001 Debugging. Nov 10, Fall 2006IAT 8002 How do I know my program is broken?  Compiler Errors –easy to fix!  Runtime Exceptions.
Python, CGI November 23, Unit 8. So Far We can write programs in Python (in theory at least) –Conditionals –Variables –While loops We can create a form.
Web Application Security An Introduction. OWASP Top Ten Exploits *Unvalidated Input Broken Access Control Broken Authentication and Session Management.
Every week: Sign in at the door If you are new: Fill in Registration Form Ask a Mentor how to get started Make sure you are on the Athenry Parents/Kids.
Estimation Wrap-up CSE 403, Spring 2008, Alverson Spolsky.
Dataface API Essentials Steve Hannah Web Lite Solutions Corp.
Lecture 3 – Data Storage with XML+AJAX and MySQL+socket.io
Lecture 7 Page 1 CS 236 Online Password Management Limit login attempts Encrypt your passwords Protecting the password file Forgotten passwords Generating.
PHP Security.
1 Introduction to PHP. 2 What is this “PHP” thing? Official description: “PHP, which stands for "PHP: Hypertext Preprocessor" is a widely-used Open Source.
Intro to Web Programming using PHP, HTTP, CSS, and Javascript Layton Smith CSE 4000.
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
Lecture 6 – Form processing (Part 1) SFDV3011 – Advanced Web Development 1.
Chapter 4 – The Building Blocks Data Types Literals Variables Constants.
Databases with PHP A quick introduction. Y’all know SQL and Databases  You put data in  You get data out  You can do processing on it very easily 
1 Web Based Programming Section 6 James King 12 August 2003.
PHP H ypertext P re-processor. Unit 6 - PHP - Hello World! - Data types - Control structures - Operators.
INFO 344 Web Tools And Development CK Wang University of Washington Spring 2014.
Jun 16, 2014IAT 2651 Debugging. Dialectical Materialism  Dialectical materialism is a strand of Marxism, synthesizing Hegel's dialectics, which proposes.
INFO 344 Web Tools And Development CK Wang University of Washington Spring 2014.
NMED 3850 A Advanced Online Design January 26, 2010 V. Mahadevan.
Moodle (Course Management Systems). Assignments 1 Assignments are a refreshingly simple method for collecting student work. They are a simple and flexible.
PHP meets MySQL.
How to think through your program [ principles of good program design ] Rachel Denison MATLAB for Cognitive Neuroscience ICN, 13 December 2007.
INFO 344 Web Tools And Development CK Wang University of Washington Spring 2014.
INFO 344 Web Tools And Development CK Wang University of Washington Spring 2014.
1 Project Information and Acceptance Testing Integrating Your Code Final Code Submission Acceptance Testing Other Advice and Reminders.
07 Coding Conventions. 2 Demonstrate Developing Local Variables Describe Separating Public and Private Members during Declaration Explore Using System.exit.
Accessing MySQL with PHP IDIA 618 Fall 2014 Bridget M. Blodgett.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
Lecture 8 – Cookies & Sessions SFDV3011 – Advanced Web Development 1.
NMD202 Web Scripting Week3. What we will cover today Includes Exercises PHP Forms Exercises Server side validation Exercises.
PHP2010/11 : [‹#›] PHP Security. PHP2010/11 : [‹#›] Two Golden Rules 1.FILTER external input Obvious.. $_POST, $_COOKIE, etc. Less obvious.. $_SERVER.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
# ACS 168 Structured Programming Using the Computer Chapter 2 Spring 2002 Prepared by Shirley White.
6/3/2016 CSI Chapter 02 1 Introduction of Flow of Control There are times when you need to vary the way your program executes based on given input.
CS 4720 Dynamic Web Applications CS 4720 – Web & Mobile Systems.
INFO 344 Web Tools And Development CK Wang University of Washington Spring 2014.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
How to organize your notes When you are done reading this, you will know: Various ways to take notes How to keep track of your sources How to NOT screw.
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
INFO 344 Web Tools And Development CK Wang University of Washington Spring 2014.
Database Access Control IST2101. Why Implementing User Authentication? Remove a lot of redundancies in duplicate inputs of database information – Your.
INFO 344 Web Tools And Development CK Wang University of Washington Spring 2014.
INFO 344 Web Tools And Development CK Wang University of Washington Spring 2014.
CSC 2720 Building Web Applications Basic Frameworks for Building Dynamic Web Sites / Web Applications.
INFO 344 Web Tools And Development CK Wang University of Washington Spring 2014.
INFO 344 Web Tools And Development CK Wang University of Washington Spring 2014.
ITM © Port,Kazman 1 ITM 352 Cookies. ITM © Port,Kazman 2 Problem… r How do you identify a particular user when they visit your site (or any.
INFO 344 Web Tools And Development CK Wang University of Washington Spring 2014.
Introduction to TouchDevelop Lesson 3 – Comments & Lists Created by S. Johnson
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
Fusebox Not Just For Breakfast Anymore! An Introduction to Fusebox Author: Fred T. Sanders, Instant Knowledge Some Content unscrupulously taken from Steve.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
Microsoft Visual C# 2010 Fourth Edition Chapter 3 Using GUI Objects and the Visual Studio IDE.
Common Methods Used to Commit Computer Crimes
Introduction to Python
And Why You Should Use It In You Websites
Loop Structures.
Coding Concepts (Basics)
INFO 344 Web Tools And Development
INFO 344 Web Tools And Development
INFO 344 Web Tools And Development
Presentation transcript:

INFO 344 Web Tools And Development CK Wang University of Washington Spring 2014

Announcements PA1 = do not write code to read csv. Just import it via phpMyAdmin (search google on how to do this) M 12:30pm to MGH 080 W 12:30pm to MGH 136 4/16 & 5/14 12:30pm to MGH 370H

Reminder! Teach you “How to Learn” I will purposely leave things out Search on Google! This will change your life. I promise.

Revisit Example of === – indexOfChar($string, $char) => look for char in string – returns 0 (index) or null (no char), we want to differentiate Example of == – $mySQL->execute() => returns null or FALSE if fails? Not sure, just do FALSE, cuz null also works – Convenient because HTML = string but for loop iteration = int, for example, if I have a year dropdown, and I press select and form submit, when the page refreshes I need to highlight the selected year, I have a for loop, 1900 to 2014, I can do == instead of === Generally use ===

PHP Best Practices

PHP files Always use not shortcuts (shortcuts might not be supported later) Leave out ?> if pure PHP file

Do not alternate outputs Output html either by typing html directly Or… echo “ …” Choose 1 or the other! Do not alternate unless in loops.

Use filter_var() Never trust user input FILTER_VALIDATE_ ) Returns the filtered data, or FALSE if the filter fails List of filters at

Single Quotes for Array keys echo myArray[key];// avoid this echo myArray['key'];// do this! Double quotes = performance hit No quotes = works now but might not in the future – define('key', 'wrongkey'); – Or if PHP decides to stop supporting this

Error Reporting For Development error_reporting(E_ALL); For Production/Release error_reporting(0);

Run-time limit Default is 30s max_execution_time value defined in the php.ini Keep this unless you have a good reason… set_time_limit(int) => for selected scripts

PHP info phpinfo() is great for developer info Do NOT use phpinfo() in production!! Easy to hack your system if they know what modules/php version you have!!! PHP exploits for older versions are public! This also means… use the latest PHP version

Use XCache PHP code Bytecode Apache XCache!!! Big performance improvement! No need to compile for every request PHP code changes much less frequently Requests can be >1000/second

Tier Code Design

Coding is an Art In general, good code design is… – Easier to understand – Easier to make changes – Less prone to bugs

Front-end Development Already learnt this! Easier to find/read Easier to update/change This is huge… imagine if you had a bug that you spent 3 hours on and it’s because a style sheet is being added at a random place?

3-tier architecture Easier to find/read Easier to add/remove layers

Example Any thoughts?

Poor Design Database code Business/Logic Presentation ALL in One function!!

Problem Very hard to modify/change anything = cannot scale! Abstraction => more scalable

3-tier architecture DatabaseBusiness Presentation Easy to make changes!

For Example What modules do I need?

Code modules User Account database User Cart data (session) Book database (title, actors, etc) Review database Logic to determine % sale Presentation = for everything

Code modules Users database Cart session data Books database Reviews database Page Logic (ex: % off) Buy Page Layout/View

Group Discussion! Groups of 3, Pick your favorite website, Pick a page, Draw the code modules! Presentation! & Submit on Canvas!

General Coding Best Practices

DRY approach Don’t Repeat Yourself Minimize copy/paste, every copy/paste => potential headaches later when you update. Easy to miss one Use functions, variables to prevent repeating

CLEAN approach Make the code look CLEAN Indent properly, line things up properly, always use {} for if and while

CONSISTENT approach Be Consistent Naming convention for variables, functions, classes need to be meaningful and consistent

WYSIWYG approach What you see is what you get What the code does should be obvious w/o comments but add comments when necessary. Instead of complex code, simplify and make it clear & easier to understand

WHY? Why DRY, Clean, Consistent, WYSIWYG? It’s better! Easier to change, update, add to, etc. Why!!!!! Ok fine. at the very least, it makes it easier for someone else to inherit so you can get promoted to work on something else! HA!

Other best practices Never store clear passwords! Always store hashes of them. Privacy and security reasons. Learn OOP. It’s crucial in almost every code base you’ll ever work on. This class isn’t about OOP so ask Google if it isn’t already clear!

Final Note Why not use PHP frameworks? Zend? Cake? Learn low level fundamentals Understand how everything works Appreciate frameworks more when you do use it

Tutorials Learn PHP in 15 minutes

Resources applications/ applications/

Questions?