Presentation is loading. Please wait.

Presentation is loading. Please wait.

Web Design: Basic to Advanced Techniques Fall 2010 Mondays 7-9pm 200 Sutardja-Dai Hall Introduction to PHP.

Similar presentations


Presentation on theme: "Web Design: Basic to Advanced Techniques Fall 2010 Mondays 7-9pm 200 Sutardja-Dai Hall Introduction to PHP."— Presentation transcript:

1 Web Design: Basic to Advanced Techniques Fall 2010 Mondays 7-9pm 200 Sutardja-Dai Hall Introduction to PHP

2 Last Week… We learned that JavaScript is awesome Functions Manipulation Effects/Animations Events/Callbacks GET/POST AJAX

3 Event handling Mouse click $(“#blah").click(function() { alert("Hello world!"); }); Hover $('#blah').mouseover(function() { alert(“Hello world!”); }); Keyup/down/press, onfocus/blur, etc. For more, check out the Jquery API: http://api.jquery.com/category/events/ http://api.jquery.com/category/events/

4 Callbacks Piece of executable code that is passed as an argument to other code Allows us control timing of function calls Allows us to execute X only if Y was sucessful. Just like the jQuery.click() $("p").click(function () { $(this).slideUp(); });

5 Callbacks If you do some AJAX call that returns data $.post(URL, input, function(output){ alert(output); }

6 What is PHP? Client Side Web Browser HTTP Request (visit website) Interpret and render received files Server Side Web Server Serve Website Send HTML and CSS files Send images Execute JavaScript Send JavaScript code PHP and MySQL Runs in your browser – on the client side

7 PHP: Hypertext Preprocessor Server-side Scripting language (like JavaScript, unlike HTML and CSS) Dynamically writes HTML pages Has access to server system’s resources Database Image processors Anything else the system can run

8 PHP Use Cases Customization Facebook shows you your profile despite sending the same file to everyone Authentication Login PHP can choose to hide your Facebook profile from those that are unauthorized to view it Access Database on your Behalf When you use Yelp, Yelp does not have html files for every search you could possibly make saved. It generates the pages on the fly.

9 Chain of Events Client Requests File Web Server sees the file is.php PHP Parses.php file requested and writes HTML HTML The result after the php code has been parsed Received by Client JavaScript Included in the HTML file is executed by client Client to Server Via Internet Server to Client Via Internet

10 PHP Generates HTML Files PHP dynamically writes HTML files which are then downloaded and rendered by the user User AUser B Profile.php w/ php code Profile.php w/ php code parsed for User A Profile.php w/ php code parsed for User B

11 Client Never Sees PHP Server View of.phpClient View of.php

12 Exchange of Data Browser Server HTML, CSS, JS, images Request for files Login, password, cookies, …

13 PHP and User Input

14 GET variables Passed via URL in the form of &myVar=value POST variables The result of form submission Can be a single word, a check box, a selector, a file Cookies Set by the server Key, value pairs

15 PHP and User Input ClientServer http://server.com?user_id=10 cookie(user_id, 10) $_COOKIE[‘user_id’] $_POST[‘user_id’] $_GET[‘user_id’]

16 GET View Profile Could use PHP to dynamically create this link too…

17 POST


Download ppt "Web Design: Basic to Advanced Techniques Fall 2010 Mondays 7-9pm 200 Sutardja-Dai Hall Introduction to PHP."

Similar presentations


Ads by Google