PHP, Database and XML/JSON
PHP, Database and XML/JSON
Introduction
You are required to develop a web application to process XML and JSON data. The application will use PHP, Database, XML, and JSON.
Preparation
1. Create a XML file which contains data of students (say, students.xml). The elements should be:
· student_id; attribute email
· lastname
· firstname
· address
2. You will need a database table which contains data used to validate users before they are able to log into the website. Create a login table in Oracle (student)database with the appropriate fields. Once a user is logged in, they should have different views depending on their privilege. A "normal" user may only lookup data in students.xml; an "administrator" should be able to insert student data into students.xml.
3. Populate students.xml and the login table with some data.
4. Download the JSON file called sensor.json from: university link(I have downloaded it, details are following) This file contains environmental data captured from environmental sensors. Users will be able to lookup data in sensor.json.
{"sensorreadinglist":[
{
"xbeeid":"B3D982A49F",
"moteid":"crest001",
"motelocation":"Canteen, ground floor",
"hubname":"hubone",
"temperature":"33.66",
"airpressure":"1011.40",
"humidity":"55.23",
"light":"180.50",
"altitude":"28493.84",
"mic":"392.38",
"gas":"0135.32"
},
{
"xbeeid":"B3D982358A",
"moteid":"crest002",
"motelocation":"Classroom Hallway, second floor",
"hubname":"hubone",
"temperature":"32.34",
"airpressure":"1010.30",
"humidity":"56.98",
"light":"240.50",
"altitude":"28503.84",
"mic":"292.38",
"gas":"0085.32"
},
{
"xbeeid":"B3D989A2DD9",
"moteid":"crest003",
"motelocation":"Football Field, ground floor",
"hubname":"hubone",
"temperature":"34.09",
"airpressure":"1011.22",
"humidity":"58.30",
"light":"280.30",
"altitude":"28504.33",
"mic":"085.38",
"gas":"0038.93"
}
]}
Requirements
1. Login page (3 marks) Create a Login page which accepts a username and password. Create two username/password for testing :
· admin/SIT780 (grant the user administrator privilege)
· guest/SIT780 (grant the user normal privilege)
Prepared statements reduce the risk of SQL injection. Hence, prepared statements need to be used to implement the login functionality. Captcha needs to be used in the login page to ensure that a human-being is attempting to login.
2. Welcome page (1 mark) After successful validation, a welcome page should be displayed. The welcome page should display a welcome message and also clearly state the privilege assigned to the user (normal or administrator). Create a menu to navigate to the options in #3, #4, #5 and #6 below.
3. Display data from sensor.json (3 marks) sensor.json contains environmental data captured from sensors placed around a school. Parse sensor.json and display data in a HTML table. Assign background color to HTML table data to highlight high/low values of temperature and humidity.
4. Display student data (3 marks) Parse students.xml and display data in a HTML table.
5. Search student data (4 marks) Provide an interface to search students.xml by firstname or lastname. Appropriate results should be displayed.
6. Insert student data (3 marks) Only an administrator should have access to this option. Provide an interface to accept values for student_id, email, lastname, firstname and address. The data should be appended to students.xml
7. Visualisation of address information in Google earth (3 marks) Enhance the requirement #4 and #5 so that each student record has a hyperlink to visualize the location information in Google Maps. Refer to the example:
which is a modification of sample code from Google Maps.
Submission
You need to submit:
2. An assignment cover sheet. It can be submitted as an attachment or as a page on your website.
3. Submit all your source files as a zipped (.zip or .rar) file.