A software company is asked to design a web-based information system for a shop which sells second - hand cars to the public. The shop wishes to provide web pages which allow prospective customers to see details (including pictures and large amounts of formatted text) of each of their favorite cars, to search for cars with specific features (including those in a particular price range). The shop naturally wishes to maintain consistent presentation across all of its pages and for the system to require minimum effort (by non-technical staff) to add and remove individual instruments from the web.
As a designer, briefly describe the technologies would you recommend implementing this website? -10 marks
Explain the advantages in favor of using an open source relational database as back end for web sites and discuss their possible relevance to the scenario described above. -10 marks
What are the alternative technologies available that could be used and why?
- 5 marks
At present, ecommerce website does not have any plans of online payments using credit/debit cards. If it wants to provide these services to their clients, how this could be implemented? Are there any changes needed for the code that already exist for the operation of the website. - 7 marks
Design a home page and provide the html code. What features do you think are essential to keep the users interest in the website? - 13 marks
Describe the steps you would take to design this system to enable you to separate design and content. - 5 marks
Answer:
The expected answer should discuss the following different technologies
HTML for front end presentation, Java Script for front end data entry validation and php programming or similar server side programming and their capabilities.
HTML is the primary format used on the World Wide Web. It can display web pages with a wide range of colors, shapes, and objects with the use of CSS(Cascading Style Sheets). HTML is highly flexible and is supported by all browsers. Most important thing it is open source.
Java script validation of forms is flexible and based on client side. Data fields are validated before submitting to the server which is faster that backend validation. It is widely used and very secured.
PHP is the most popular server side web programming language. It is platform independent, faster and open source.
Open source database like MySQL, Postgre SQL, or Oracle 10g Express can be used.
As all data is saved in the database, data is secured and protected and available for authorized users.
As its open source, it economically competitive.
Only the front end web interface has to be designed.
Searching would be must faster compared to other types of data storage
Site could be configured to individual users
Alternate technologies; JSP, ASP, PERL, Cold Fusion etc. can also be used. These languages are also open source and can be used to fulfill the requirements. For example: with ASP dynamic and interactive webpages can be created, perl is a great language for use in CGI development and general processing and cold fusion can be used to query processing from database.
It can be implemented using secured transactions, for example SSL, SHTTP etc. The code doesn't have to be changed.
This tests students' design and presentation skills. Main features include a search facility, a clickable navigation map, a FAQ, A variety of processing options.
XML database can be used
Data can be separated into xml files.
Presentation can be separated into either CSS or XSLT
Different style sheets can be applied to same data
HTML pages are used to display data. Data is often stored inside HTML pages. With XML this data can now be stored in a separate XML file. CSS manages to separate the styles from the contents on web pages and apply them when required.
Question 2
You have been commissioned to develop an ecommerce website called eshore.co.uk. The system must provide features for selling and buying for business to consumer (B2C) and Consumer to consumer (C2C) customers. Other main features of selling include buy it items, auction items. Buyers can pay for their purchase by cheque, credit card or pay pal. However, at the moment only cheque is accepted. In future, there is an option for credit card and paypal.
As a designer, what technologies would you recommend to implement this website? - 7 marks
Include in your answer a brief discussion of the capabilities of each of these technologies. - 11 marks
What are the alternative technologies available that could be used and why?
- 7 marks
At present, eshore.co.uk does not have any plans of online payments using credit/debit cards. If it wants to provide these services to their clients, how this could be implemented? Are there any changes needed for the code that already exist for the operation of the website. - 7 marks
Design a home page and provide the html code. What features do you think are essential to keep the users interest in the website? - 13 marks
All transactions online are said to be stateless. How is that maintained in an ecommerce website? - 5 marks
Answer
The expected answer should discuss the following different technologies
HTML for front end presentation, Java Script for front end data entry validation and Perl programming or similar server side programming.
Capabilities of all the above
Alternate technologies; JSP, ASP, PHP, Cold Fusion etc and their explanation
Implemented using secured transactions, for example SSL, SHTTP etc. The code doesn't have to be changed.
This tests students' design and presentation skills. Main features include a search facility, a clickable navigation map, a FAQ, A variety of processing options.
It is maintained through the following steps:
The client connects to the server and sends a request.
The server sends a response and connection is lost.
The server and client do not know each other after words.
With these points, student has to explain with examples.
Session, hidden fields and URL rewriting can be used to illustrate this.
Short Questions and Answers
Explain how do you get (read) the data that is submitted by the client using a POST method, in a php program.
Answer
All the data submitted by the client to server is available in a predefined array variable called $_POST. The server program must use $_POST to fetch the parameter values.
For example, $name=$_POST['name'], where name is the name of the parameter.
How to deploy PHP to WAMP server?
Answer:
WAMP is a form of mini-server that can run on almost any operating systems. WAMP includes Apache, PHP and MySQL preinstalled. So to deploy a php program to WAMP, we need to save the .php file in the root directory(default is www folder inside wamp directory) of WAMP and then run it using the web browser through http protocol.
For example: If we want to run xyz.php file using wamp, then we need to save the file in www folder inside WAMP folder and then type http ://localhost/xyz.php in the web browser to execute it.
Critically evaluate the differences between static and dynamic web pages and justify why such pages are needed in real world applications. What are the advantages and disadvantages.
Answer
Static web pages are hard coded and retrieved by the server and sent to the client. The content remains same for the life of the page unless it is changed.
Advantages:
Quick to develop
Cheap to develop
Cheap to host
Disadvantages
Requires web development expertise to update site
Site not as useful for the user
Content can get stagnant
Dynamic web pages are generated by the CGI application and the content can be easily changed.
Advantages:
Much more functional website
Much easier to update
New content brings people back to the site and helps in the search engines
Can work as a system to allow staff or users to collaborate
Disadvantages:
Slower / more expensive to develop
Hosting costs a little more
What is statelessness of http protocol?
Answer
A comment "The HTTP protocol is a stateless protocol, and the Internet is a stateless development environment" is often used. This simply means that the Hyper Text Transfer Protocol that is the backbone of the Web is unable to retain a memory of the identity of each client that connects to a Web site and therefore treats each request for a Web page as a unique and independent connection, with no relationship whatsoever to the connections that preceded it. This is the statelessness of http protocol.
What are php superglobals?
Answer
Superglobals are built-in variables in php that are always available in all scopes.
The php superglobals are:
$GLOBALS
$_GET
$_POST
$_COOKIE
$_REQUEST
$_SESSION
$_SERVER
$_ENV
$_FILES
What are absolute and relative URLs? Explain briefly with examples.
Answer
Absolute URL: An URL that is ABSOLUTE shows the complete address. In other words, there is no confusion about where this item is located.
Example: www.yahoo.com/images/me.jpg
Relative URL: An URL that is RELATIVE only shows a partial address. The success or failure of finding the file will vary, depending largely how the directories within your website are structured.
Example: images/me.jpg
Assume that there is a php program called parameters.php saved on the web server (for example apache)
How do you invoke this program without HTML document?
How do you send data to a program on the server without html document?
Answer
By typing the URL in the browser URL window. The URL includes the PHP script name ending with .php. For Perl script it will be .pl or .cgi
Data is sent using the query string.
Example: Using an URL : http://someurl.com/page.php?a=1&b=2&c=3
data which is send for program that requires the value of a, b, c is a=1,b=2,c=3
What is the difference between GET and POST methods?
Answer:
GET: Parameters are passed in the query string. Maximum amount of data that can be sent via the GET method is limited. GET request can be bookmarked. It method is less secured. Get request can be created by html form or without html form.
POST: Parameters are passed in the request body. There is no limit to the amount of data that can be transferred using POST request. POST request cannot be bookmarked. Data is hidden and secured in POST method. Post request can only be done using html form.
Consider the following database table that stores student id, subject and grade as a row as shown below
StudentID
Subject
Grade
001KD1006
SSWP
CR
001KD1006
MLA
CR
001KD1006
CSA
PS
001KD1006
ITP
PS
002SB1006
SSWP
PS
002SB1006
MLA
PS
002SB1006
CSA
CR
002SB1006
ITP
DI
Your task is to create a PHP page that displays the data as a shown below. You do not have to provide the full code for this. However, you have to explain how you would achieve this. What PHP functions would you use?
StudentID
SSWP
MLA
CSA
ITP
001KD1006
CR
CR
PS
PS
002SB1006
PS
PS
CR
DI
Answer
The above scenario occurs in many situations when row data is to be displayed as column data. This could be done by assigning all retrieved data into an array and then imploding the array to convert into text in suitable html format. For this the main data structure would be an array and PHP function called implode.
Main logic:
Create a new array to hold row data
Retrieve the rows from the database
Loop through the data and assign it to an array embedding with suitable html tags like <tr><td> to format the data in suitable format
Convert the array data into a string using implode function
Display it as html tags
Consider the following table Item, which has the following structure and sample data.
Category
Description
Price
Electronics
42" Flat Screen TV
£1200
Electronics
MP3 Player
£25
Garden Equipment
Lawn Mower
£55
Develop a PHP page that fetches all the Item details from MySQL database and generates HTML page by embedding all the data. You can assume your own database name, host, username and password. The data should be properly formatted using html <table> element
Answer
<head>
<title>Title goes here</title>
</head>
<body>
<?php
// Connect to the MySQL server.
$conn = mysql_connect("localhost", "user", "password");
// Select the database to use.
mysql_select_db("sis44");
$query = "select * from Item;
$result=mysql_query($query);
echo "<html><head><title>Item List</title></head>";
echo "<body><table border='1'>\n";
echo "<tr><th>Category</th><th>Description</th>";
echo "<th>Price</th></tr>";
while($row=mysql_fetch_row($result))
{
echo "<tr><td>$row[0]</td><td>$row[1]</td>";
echo "<td>$row[2]</td></tr>";
}
?>
</table>
</body>
</html>
Create a web page to display similar to the following. You need to write html tags for this.
Write a PHP program that is invoked when the user submits the above form by clicking the Calculate button. The form can use POST method to submit the data. The program should display the result for the selected arithmetic operation. For example if user entered 5 and 9 for the first two fields and selected add radio button, then the php should send the following page to the client browser. - 9 marks
Answer
HTML
<html><head>
<title>Calculator</title>
</head><body>
<form action="calculate.php" method ="POST">
<table>
<tr><td>Enter Value:</td><td><input type="text" name="number1"></td></tr>
<tr><td>Enter Value:</td><td><input type="text" name="number2"></td></tr>
<tr><td>Add: </td><td><input type="radio" name="result" value="add"></td></tr>
<tr><td>Subtract: </td><td><input type="radio" name="result" value="subtract"></td></tr>
<tr><td>Multiply: </td><td><input type="radio" name="result" value="multiply"></td></tr>
<tr><td>Divide: </td><td><input type="radio" name="result" value="divide"></td></tr>
<tr><td><input type="submit" value="Calculate">
</form><table/>
</body>
</html>
PHP
<html><head>
<title>calculator</title>
</head>
<body>
<?php
$num1=$_POST['number1'];
$num2=$_POST['number2'];
$radio=$_POST['result'];
if ($radio=="add"){
$calculation = $num1+$num2;
echo"The result is: $calculation";}
elseif ($radio=="subtract"){
$calculation = $num1-$num2;
echo"The result is: $calculation";}
elseif ($radio=="multiply"){
$calculation = $num1*$num2;
echo"The result is: $calculation";}
elseif ($radio=="divide"){
$calculation = $num1/$num2;
echo"The result is: $calculation";}
else
echo "Invaid Operation";
?>
</body>
</html>
What are html entities?
Answer:
How does a client browser send the data that contains reserved characters, for example the characters '/', ':' etc to the server. What does it do to interpret them in a different way.
Answer:
Many characters must be encoded within a URL for a variety of reasons.
Certain characters such as?, # and / have special meaning within URLs and will be misinterpreted unless encoded.
Characters are encoded by representing them with a percent sign followed by the two-digit hexadecimal value for that character based upon the ISO Latin 1 character set or ASCII character set
Compare and contrast the server and client content side negotiation.
Answer:
In server-side negotiation, the client sends a header indicating the forms of content it accepts, and the server responds by selecting one of these options and returning the resource in appropriate format
In client-side negotiation, the client requests a resource without special headers, the server sends a list of available contents to the client, the client then makes an additional request to specify the format of the resource.
Explain the elements of the following URL
http://www.oreilly.com:80/cgi/calender.cgi?month=nov#week3
http://www.ebay.co.uk/items/itemslist.php?itemid=100&category=e
Answer:
Scheme: http
Host name: www.oreilly.com
Port number:80
Path information: cgi/calender.cgi
Query string: month=nov
Fragment identifier:week3
And
Scheme: http
Host name: www.ebay.co.uk
Port number:80
Path information: items/itemlist
Query string: itemid=100&category=e
What are proxies? What is the purpose of setting up a proxy server? - 4 marks
Answer
A server that sits between a client application, such as a Web browser, and a real server. It intercepts all requests to the real server to see if it can fulfil the requests itself. If not, it forwards the request to the real server.
Proxy servers have two main purposes:
Improve Performance
Filter Requests
Assume that there is a PHP program called parameters.php saved on the web server (for example apache)
How do you invoke this CGI/PHP program without HTML document?
Answer
By typing the URL in the browser URL window. The URL includes the perl script name ending with either pl or cgi
How do you send data to a program on the server without html document? - 1.5 mark
Answer
Data is sent using the query string. Format of query string must be explained here, with an example
PUT and DELETE are the request methods that could be used to invoke a script on the server. However, these are not used in server side scripting. Discuss. - 3 marks
Answer
PUT and DELETE methods are dangerous, which can destroy your computer resources and fort hard drive etc. Hence, they are not allowed to be used in CGI programming.
The usual way to address the security issues with systems such as eshore.co.uk to pay online is to use SSL. Explain how SSL works. In your answer explain the role of certifying authorities and digital certificates. Explain also how SSL uses symmetric and asymmetric keys. Discuss also the client and server software required for SSL to work.
The simplest way to provide authenticated access to the system would be to use HTTP Basic Authentication. Is this inadequate for eshore.co.uk? Aside from SSL, what alternatives are there for providing secure authenticated access?
Answer
The answer should discuss,
SSL, Secure Socket Layer,
Certifying Authorities,
Digital certificates
Symmetric and Asymmetric cryptography
HTTP Basic Authentication may be sufficient for the system. However, the student has to explain the disadvantages of Basic Authentication. If Video Rental System accepts credit card payments, then SSL or other more secured technology must be used.
HTTPS must be discussed as an alternative technology.
Write a php function that accepts two inputs, which are assignment marks, exam marks and returns the result based on the following criteria:
Total marks= 30% of assignment marks + 70% of exam marks
if total marks < 40, the result is FAIL
if 40<=total marks<60, the result is PS
if 60<=total marks<70, the result is CR
else result is DI
Answer:
AWrite down the output of the following PHP code. What would it produce when it is rendered by the browser? - 6 marks
$query="SELECT id,date_format(term, '%M %y' ) FROM term order by term desc";
$result =mysql_query($query);
echo "<td>Intake: <select name='term'>";
while ($row = mysql_fetch_row($result))
echo "\t<option value =$row[0]>$row[1]</option>\n";
echo "</select></td>";
echo "\n";
Answer
It selects two columns called id and term which is a date formatted in the format of Month and Year, for example 'Jun 06'
It constructs the <select > tag embedding all data retrieved from the database.
It displays dropdown list of options when rendered by the browser.
Develop a php program called AcceptUsername.php that accepts the data from the above form and generates a form like the one shown below that contains a username field with the data from the form, along with given name, family name and age fields.
Create a second program called AcceptDetails.php that accepts the data from the above form generated by the above program and displays 'Hello given_name family_name, your username is username and soon you will be age + 1' as shown below.
Answer:
<html>
<body>
<?php
if($_SERVER['REQUEST_METHOD']=='GET')
{
echo "<form method=POST action=AcceptUsername.php>";
echo "<pre>Username :<input type=text name=username size=15/>";
echo "<pre>Given name :<input type=text name=givenname
size=15 />";
echo "<pre>Family name:<input type=text name=familyname size=15 />";
echo "<pre>Age :<input type=text name=age size=15 />";
echo "<pre> <input type=submit value=Submit />";
echo "</form>";
}
else
{
$username=$_POST['username'];
$familyname=$_POST['givenname'];
$givenname=$_POST['familyname'];
$age=$_POST['age'];
$age=$age+1;
echo "<h1> Hello $givenname $familyname, your username is $username and soon you will be $age</h1>";
}
?>
</body>
</html>
Consider the following PHP fragments:
1. $first_name = 'Bill';
2. $last_name = "Gates";
3. $name1 = '$first_name $last_name';
4. $name2 = "$first_name $last_name";
5. print $name1;
6. print $name2;
What is the difference between two lines 3 and 4?
What is printed for lines 5 and 6?
Answer
The difference between line 3 and 4 is that in line 3 single quotes are used which does not parse variable value but in line 4 double quotes are used which will parse variable value.
In line 5 it will be printed: $first_name $last_name
In line 6 it will be printed: Bill Gates
Explain very briefly the different request methods - 5 marks
Explain different request headers briefly - 3 marks
Create an html web page that displays the following screen. Please note, you must use only one input control to receive the input for Event days
Write a PHP code that reads the above form input and displays on the screen
What are indexed and associative arrays? Illustrate the difference between them with an example.
Consider the following PHP fragment:
$soups = array (
'Monday' => 'Clam Chowder',
'Tuesday' => 'White Chicken Chili',
'Wednesday' => 'Vegetarian'
);
print "$soups";
print_r ($soups);
What is the output for the above two outputs? Discuss the difference between print and print_r?
Create php program that accepts a number say 'n' and provides a submit button. When user presses the submit button, then the same page should print the first 'n' prime numbers.