Download presentation
Presentation is loading. Please wait.
1
NMD202 Web Scripting Week9
2
What we will cover today
Solution exercise last week Ajax and PHP Exercises PHP Ajax Frameworks Assignment 1
3
Exercise Create a username/password table and use it to store usernames and password hashes. Use 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)
4
Ajax and PHP What is AJAX?
5
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.
6
Ajax and PHP
7
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);
8
Ajax and PHP Check example at:
9
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
10
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
11
PHP Ajax Frameworks Ajax Agent
Simple Framework that handles simple Ajax Calls
12
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)
13
PHP Ajax Frameworks Ajax Agent
Check Example at:
14
Rewrite last exercise using Ajax Agent
15
Assignment 1
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.