150 likes | 228 Views
NMD202 Web Scripting. Week9. What we will cover today. Solution exercise last week Ajax and PHP Exercises PHP Ajax Frameworks Exercises Assignment 1. Exercise. Create a username/password table and use it to store usernames and password hashes.
E N D
NMD202 Web Scripting Week9
What we will cover today Solution exercise last week Ajax and PHP Exercises PHP Ajax Frameworks Exercises Assignment 1
Exercise Create a username/password table and use it to store usernames and password hashes. Use http://md5-hash-online.waraxe.us/ to create hashes Use cookies and sessions to confirm authentication. Use a salt to harden your hashes (don’t forget to include the salt when calculating hashes for the user table)
Ajax and PHP What is AJAX?
Ajax and PHP Technique that allows exchanging small amounts of data with the server "behind the scenes" so that entire web pages do not have to be reloaded each time there is a need to fetch data from the server.
AJAX and PHP var xmlHttp=null; try { xmlHttp = new XMLHttpRequest(); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlHttp.onreadystatechange = function() { if (xmlHttp.readyState == 4) { document.getElementById("ajax_output").innerHTML = xmlHttp.responseText; } } xmlHttp.open("get","pages/index.html"); xmlHttp.send(null);
Ajax and PHP Check example at: http://learnline.cdu.edu.au/units/webscripting/classmaterials/source/ajax/
Exercise Build a Filter on the student list that filters the list of students based on the student name. ie: user inserts ‘L’ all users starting with L will be displayed. Tip: Use a Like statement
PHP Ajax Frameworks Frameworks Make PHP Ajax development very simple Some you don't even have to write any PHP Most use PHP Object Oriented Features
PHP Ajax Frameworks Ajax Agent Simple Framework that handles simple Ajax Calls http://ajaxagent.org
PHP Ajax Frameworks Ajax Agent 1-Include agent.php file 2-Initialize Agent ($agent->init(); ) this will write all necessary javascript to handle Ajax Calls 3- Call the agent – agent.call(url,phpFunction,callBackFunction,[list of variables]); url – URL where the php functions is located, leave empty for current page phpFunction – Server side functions to be called by ajax callBackfunction – Client Side function to run after ajax request has finished [list of variables] - Optional variables to pass to the server side function (comma separated)
PHP Ajax Frameworks Ajax Agent Check Example at: http://learnline.cdu.edu.au/units/webscripting/classmaterials/source/ajaxAgent/
Exercise Rewrite last exercise using Ajax Agent